diff options
author | isaacs <i@izs.me> | 2013-02-21 12:22:12 -0800 |
---|---|---|
committer | isaacs <i@izs.me> | 2013-02-21 15:18:44 -0800 |
commit | 089ec586135726e82dc0d25c2e328478d577db24 (patch) | |
tree | d70b638330ae8ee3715d4f355c86bbac47f79091 /lib/path.js | |
parent | 50c88e0ff24890cadf2f1730a0eb93ebd0a63c28 (diff) | |
download | node-new-089ec586135726e82dc0d25c2e328478d577db24.tar.gz |
path: Throw TypeError on non-string args to path.resolve
Diffstat (limited to 'lib/path.js')
-rw-r--r-- | lib/path.js | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/lib/path.js b/lib/path.js index 9958630d7b..c920580fec 100644 --- a/lib/path.js +++ b/lib/path.js @@ -112,7 +112,9 @@ if (isWindows) { } // Skip empty and invalid entries - if (typeof path !== 'string' || !path) { + if (typeof path !== 'string') { + throw new TypeError('Arguments to path.resolve must be strings'); + } else if(!path) { continue; } @@ -199,9 +201,9 @@ if (isWindows) { exports.join = function() { function f(p) { if (typeof p !== 'string') { - throw new TypeError('Arguments to join must be strings'); + throw new TypeError('Arguments to path.join must be strings'); } - return p && typeof p === 'string'; + return p; } var paths = Array.prototype.filter.call(arguments, f); @@ -307,7 +309,9 @@ if (isWindows) { var path = (i >= 0) ? arguments[i] : process.cwd(); // Skip empty and invalid entries - if (typeof path !== 'string' || !path) { + if (typeof path !== 'string') { + throw new TypeError('Arguments to path.resolve must be strings'); + } else if (!path) { continue; } @@ -353,9 +357,9 @@ if (isWindows) { var paths = Array.prototype.slice.call(arguments, 0); return exports.normalize(paths.filter(function(p, index) { if (typeof p !== 'string') { - throw new TypeError('Arguments to join must be strings'); + throw new TypeError('Arguments to path.join must be strings'); } - return p && typeof p === 'string'; + return p; }).join('/')); }; @@ -454,6 +458,7 @@ exports.existsSync = util.deprecate(function(path) { if (isWindows) { exports._makeLong = function(path) { + // Note: this will *probably* throw somewhere. if (typeof path !== 'string') return path; |