diff --git a/lib/path.js b/lib/path.js index e278c891482070..884da4cd8e6822 100644 --- a/lib/path.js +++ b/lib/path.js @@ -95,7 +95,10 @@ function normalizeString(path, allowAboveRoot, separator, isPathSeparator) { lastSegmentLength = 2; } } else { - res += (res.length > 0 ? separator : '') + path.slice(lastSlash + 1, i); + if (res.length > 0) + res += `${separator}${path.slice(lastSlash + 1, i)}`; + else + res = path.slice(lastSlash + 1, i); lastSegmentLength = i - lastSlash - 1; } lastSlash = i;