summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/path.js17
-rw-r--r--test/simple/test-path.js3
2 files changed, 14 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;
diff --git a/test/simple/test-path.js b/test/simple/test-path.js
index 43bddfbe7b..da076d494d 100644
--- a/test/simple/test-path.js
+++ b/test/simple/test-path.js
@@ -287,6 +287,9 @@ joinThrowTests.forEach(function(test) {
assert.throws(function() {
path.join(test);
}, TypeError);
+ assert.throws(function() {
+ path.resolve(test);
+ }, TypeError);
});