path: improve normalization performance
PR-URL: https://github.com/nodejs/node/pull/28948 Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Gus Caplan <me@gus.host>
This commit is contained in:
parent
e3f4ec94b8
commit
37d27486fc
@ -95,7 +95,10 @@ function normalizeString(path, allowAboveRoot, separator, isPathSeparator) {
|
||||
lastSegmentLength = 2;
|
||||
}
|
||||
} else {
|
||||
res += (res.length > 0 ? separator : '') + path.slice(lastSlash + 1, i);
|
||||
if (res.length > 0)
|
||||
res += `${separator}${path.slice(lastSlash + 1, i)}`;
|
||||
else
|
||||
res = path.slice(lastSlash + 1, i);
|
||||
lastSegmentLength = i - lastSlash - 1;
|
||||
}
|
||||
lastSlash = i;
|
||||
|
Loading…
x
Reference in New Issue
Block a user