Skip to content

Commit 5c84953

Browse files
wchargintargos
authored andcommitted
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: #22273 Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent db79276 commit 5c84953

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

lib/path.js

+9-11
Original file line numberDiff line numberDiff line change
@@ -77,18 +77,16 @@ function normalizeString(path, allowAboveRoot, separator, isPathSeparator) {
7777
res.charCodeAt(res.length - 2) !== CHAR_DOT) {
7878
if (res.length > 2) {
7979
const lastSlashIndex = res.lastIndexOf(separator);
80-
if (lastSlashIndex !== res.length - 1) {
81-
if (lastSlashIndex === -1) {
82-
res = '';
83-
lastSegmentLength = 0;
84-
} else {
85-
res = res.slice(0, lastSlashIndex);
86-
lastSegmentLength = res.length - 1 - res.lastIndexOf(separator);
87-
}
88-
lastSlash = i;
89-
dots = 0;
90-
continue;
80+
if (lastSlashIndex === -1) {
81+
res = '';
82+
lastSegmentLength = 0;
83+
} else {
84+
res = res.slice(0, lastSlashIndex);
85+
lastSegmentLength = res.length - 1 - res.lastIndexOf(separator);
9186
}
87+
lastSlash = i;
88+
dots = 0;
89+
continue;
9290
} else if (res.length === 2 || res.length === 1) {
9391
res = '';
9492
lastSegmentLength = 0;

0 commit comments

Comments
 (0)