From bbcb8b3ae09cafd8dfb0e3e5dcac0df6df418f6c Mon Sep 17 00:00:00 2001 From: isaacs Date: Mon, 18 Feb 2013 10:46:50 -0800 Subject: [PATCH] path: Do not coerce paths to strings on Windows Fix #4795 --- lib/path.js | 4 +++- test/simple/test-path-makelong.js | 14 ++++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/lib/path.js b/lib/path.js index 7970ed130b..6685399bdc 100644 --- a/lib/path.js +++ b/lib/path.js @@ -448,7 +448,9 @@ exports.existsSync = util.deprecate(function(path) { if (isWindows) { exports._makeLong = function(path) { - path = '' + path; + if (typeof path !== 'string') + return path; + if (!path) { return ''; } diff --git a/test/simple/test-path-makelong.js b/test/simple/test-path-makelong.js index 0ec298fe3d..d9d8efd405 100644 --- a/test/simple/test-path-makelong.js +++ b/test/simple/test-path-makelong.js @@ -19,11 +19,11 @@ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. -if (process.platform === 'win32') { - var assert = require('assert'); - var path = require('path'); - var common = require('../common'); +var assert = require('assert'); +var path = require('path'); +var common = require('../common'); +if (process.platform === 'win32') { var file = path.join(common.fixturesDir, 'a.js'); var resolvedFile = path.resolve(file); @@ -36,3 +36,9 @@ if (process.platform === 'win32') { assert.equal('\\\\.\\pipe\\somepipe', path._makeLong('\\\\.\\pipe\\somepipe')); } + +assert.equal(path._makeLong(null), null); +assert.equal(path._makeLong(100), 100); +assert.equal(path._makeLong(path), path); +assert.equal(path._makeLong(false), false); +assert.equal(path._makeLong(true), true);