use Java's File/URI classes to convert between paths and URIs (#203)

This commit is contained in:
Jeff Williams 2012-09-29 21:07:58 -07:00
parent 0fdcdd0794
commit 46959b53a1
2 changed files with 2 additions and 31 deletions

View File

@ -198,7 +198,6 @@ function main() {
},
resolver,
fs = require('fs'),
os = require('os'),
path = require('path'),
Config = require('jsdoc/config');
@ -230,14 +229,7 @@ function main() {
scheme;
if (env.vm === 'rhino') {
result = result.replace(/\\/g, '/').replace(/ /g, '%20');
scheme = 'file:';
if ( os.platform() === 'win32' ) {
scheme += '/';
}
result = scheme + result;
result = new java.io.File(result).toURI() + '';
}
return result;
@ -254,13 +246,7 @@ function main() {
scheme;
if (env.vm === 'rhino') {
result = result.replace(/%20/g, ' ');
scheme = 'file:';
if ( os.platform() === 'win32' ) {
scheme += '/';
}
result = result.replace( new RegExp('^' + scheme), '' );
result = new java.io.File( new java.net.URI(result) ) + '';
}
return result;

View File

@ -1,15 +0,0 @@
/**
* Emulate the Node.js `os` module.
* @see http://nodejs.org/api/os.html
*/
exports.platform = function() {
var osname = java.lang.System.getProperty("os.name").toLowerCase() + '';
// obviously this isn't right, but we probably just need to distinguish between Windows/Cygwin/
// MinGW and everything else
if ( osname.indexOf('windows') !== -1 ) {
return 'win32';
} else {
return 'linux';
}
};