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:
Gürgün Dayıoğlu authored and Antoine du Hamel committed 2026-01-19 19:19:31 +01:00
1 parent ba318c5d44
commit d65326c4e6
1 file changed
+6 -2
+6 -2
View File
@@ -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) {