Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 5c84953

Browse filesBrowse 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 <ruben@bridgewater.de> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent db79276 commit 5c84953
Copy full SHA for 5c84953

File tree

Expand file treeCollapse file tree

1 file changed

+9
-11
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+9
-11
lines changed
Open diff view settings
Collapse file

‎lib/path.js‎

Copy file name to clipboardExpand all lines: lib/path.js
+9-11Lines changed: 9 additions & 11 deletions
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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.