diff --git a/lib/path.js b/lib/path.js index 90129f1f52989e..c8d92f14af04de 100644 --- a/lib/path.js +++ b/lib/path.js @@ -77,18 +77,16 @@ function normalizeString(path, allowAboveRoot, separator, isPathSeparator) { res.charCodeAt(res.length - 2) !== CHAR_DOT) { if (res.length > 2) { const lastSlashIndex = res.lastIndexOf(separator); - if (lastSlashIndex !== res.length - 1) { - if (lastSlashIndex === -1) { - res = ''; - lastSegmentLength = 0; - } else { - res = res.slice(0, lastSlashIndex); - lastSegmentLength = res.length - 1 - res.lastIndexOf(separator); - } - lastSlash = i; - dots = 0; - continue; + if (lastSlashIndex === -1) { + res = ''; + lastSegmentLength = 0; + } else { + res = res.slice(0, lastSlashIndex); + lastSegmentLength = res.length - 1 - res.lastIndexOf(separator); } + lastSlash = i; + dots = 0; + continue; } else if (res.length === 2 || res.length === 1) { res = ''; lastSegmentLength = 0;