path: remove unnecessary if statement

There is an `if`-statement in `normalizeString` (a helper function for
`path.normalize`) whose `else`-branch is never taken. This patch
removes it.

PR-URL: https://github.com/nodejs/node/pull/22273
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
pull/22273/merge
William Chargin 2018-08-11 11:23:42 -07:00 committed by Michaël Zasso
parent 80076cb1c7
commit aecfea4c44
No known key found for this signature in database
GPG Key ID: 770F7A9A5AE15600
1 changed files with 9 additions and 11 deletions

View File

@ -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;