diff --git a/lib/path.js b/lib/path.js index c5db4437a52408..ed0743d313a69a 100644 --- a/lib/path.js +++ b/lib/path.js @@ -368,20 +368,19 @@ const win32 = { if (args.length === 0) return '.'; - let joined; - let firstPart; - for (let i = 0; i < args.length; ++i) { - const arg = args[i]; + let joined = null; + let firstPart = null; + for (const arg of args) { validateString(arg, 'path'); if (arg.length > 0) { - if (joined === undefined) + if (joined === null) joined = firstPart = arg; else joined += `\\${arg}`; } } - if (joined === undefined) + if (joined === null) return '.'; // Make sure that the joined path doesn't start with two slashes, because