diff --git a/lib/internal/url.js b/lib/internal/url.js index a1473fdac8aba3..736f23101014b9 100644 --- a/lib/internal/url.js +++ b/lib/internal/url.js @@ -1472,7 +1472,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 @@ -1578,7 +1581,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) {