mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
url: add fast path to getPathFromURL decoder
PR-URL: https://github.com/nodejs/node/pull/60749 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Aviv Keller <me@aviv.sh>
This commit is contained in:
@@ -1463,7 +1463,10 @@ function getPathFromURLWin32(url) {
|
||||
}
|
||||
}
|
||||
pathname = SideEffectFreeRegExpPrototypeSymbolReplace(FORWARD_SLASH, pathname, '\\');
|
||||
pathname = decodeURIComponent(pathname);
|
||||
// Fast-path: if there is no percent-encoding, avoid decodeURIComponent.
|
||||
if (StringPrototypeIncludes(pathname, '%')) {
|
||||
pathname = decodeURIComponent(pathname);
|
||||
}
|
||||
if (hostname !== '') {
|
||||
// If hostname is set, then we have a UNC path
|
||||
// Pass the hostname through domainToUnicode just in case
|
||||
@@ -1569,7 +1572,8 @@ function getPathFromURLPosix(url) {
|
||||
}
|
||||
}
|
||||
}
|
||||
return decodeURIComponent(pathname);
|
||||
// Fast-path: if there is no percent-encoding, avoid decodeURIComponent.
|
||||
return StringPrototypeIncludes(pathname, '%') ? decodeURIComponent(pathname) : pathname;
|
||||
}
|
||||
|
||||
function getPathBufferFromURLPosix(url) {
|
||||
|
||||
Reference in New Issue
Block a user