Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
url: add fast path to getPathFromURL decoder
  • Loading branch information
gurgunday committed Nov 16, 2025
commit 0bd997f1b1ea99e679fda2ce7ebfe384df8f2fd3
8 changes: 6 additions & 2 deletions lib/internal/url.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 (StringPrototypeIndexOf(pathname, '%') !== -1) {
pathname = decodeURIComponent(pathname);
}
if (hostname !== '') {
// If hostname is set, then we have a UNC path
// Pass the hostname through domainToUnicode just in case
Expand Down Expand Up @@ -1578,7 +1581,8 @@ function getPathFromURLPosix(url) {
}
}
}
return decodeURIComponent(pathname);
// Fast-path: if there is no percent-encoding, avoid decodeURIComponent.
return StringPrototypeIndexOf(pathname, '%') !== -1 ? decodeURIComponent(pathname) : pathname;
}

function getPathBufferFromURLPosix(url) {
Expand Down
Loading