Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/path.js4
-rw-r--r--test/parallel/test-path-parse-format.js15
2 files changed, 17 insertions, 2 deletions
diff --git a/lib/path.js b/lib/path.js
index f8d0e822bf1..001152866ff 100644
--- a/lib/path.js
+++ b/lib/path.js
@@ -960,7 +960,7 @@ const win32 = {
format: function format(pathObject) {
if (pathObject === null || typeof pathObject !== 'object') {
throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'pathObject', 'Object',
- typeof pathObject);
+ pathObject);
}
return _format('\\', pathObject);
},
@@ -1503,7 +1503,7 @@ const posix = {
format: function format(pathObject) {
if (pathObject === null || typeof pathObject !== 'object') {
throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'pathObject', 'Object',
- typeof pathObject);
+ pathObject);
}
return _format('/', pathObject);
},
diff --git a/test/parallel/test-path-parse-format.js b/test/parallel/test-path-parse-format.js
index 24e49f3ffc9..1c3bdff130f 100644
--- a/test/parallel/test-path-parse-format.js
+++ b/test/parallel/test-path-parse-format.js
@@ -207,4 +207,19 @@ function checkFormat(path, testCases) {
testCases.forEach(function(testCase) {
assert.strictEqual(path.format(testCase[0]), testCase[1]);
});
+
+ function typeName(value) {
+ return value === null ? 'null' : typeof value;
+ }
+
+ [null, undefined, 1, true, false, 'string'].forEach((pathObject) => {
+ assert.throws(() => {
+ path.format(pathObject);
+ }, common.expectsError({
+ code: 'ERR_INVALID_ARG_TYPE',
+ type: TypeError,
+ message: 'The "pathObject" argument must be of type Object. Received ' +
+ 'type ' + typeName(pathObject)
+ }));
+ });
}