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

1 file changed

Lines changed: 9 additions & 11 deletions

File tree

‎lib/path.js‎

Lines 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
constlastSlashIndex=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
}elseif(res.length===2||res.length===1){
9391
res='';
9492
lastSegmentLength=0;

0 commit comments

Comments
 (0)