feat: replace deprecated url.resolve() and url.parse() with WHATWG URL - #1996
Open
dianager wants to merge 8 commits into
Open
feat: replace deprecated url.resolve() and url.parse() with WHATWG URL#1996dianager wants to merge 8 commits into
dianager wants to merge 8 commits into
Conversation
dianager
force-pushed
the
feat/replace-url-apis
branch
from
July 31, 2026 08:52
0212483 to
039fbab
Compare
* feat: remove production vulnerabilities * feat: replace uuid for crypto --------- Co-authored-by: dvinakur <dvinakur@netflix.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pre-Submission Checklist
make prepushIssues
Closes:
Changes
Deprecated API Fixes
url.parse()/url.resolve()— removed in Node.js 24.req.getUrl()now returns a WHATWGURL(semver-major)Breaking changes
req.getUrl()shape changed — no longer a legacyurl.parse()object..query,.path,.auth,.slashesare gone (silentlyundefined, no error). Use.searchParams,.pathname+.search,.username/.passwordinstead. Note.auth/.slasheswere already unreliable on the old object for normal (origin-form) requests, so this mainly affects.query/.pathconsumers. Also:.port/.hostno longer include an explicitly-sent default port (:80/:443) the wayurl.parse()did.req.href()/getHref()is now absolute, not relative (e.g.http://host/foo?a=1instead of/foo?a=1).res.redirect(), which was rewritten to build theLocationheader viaURL/URLSearchParamsinstead ofurl.format/mergeQs— behavior is preserved (see new redirect tests) but the implementation is new.req.path()/getPath()now normalizes the path — collapses..//./segments (converting\to/was already the case pre-migration, not new). A literal/foo/../barnow returns/bar. This changes whatlib/plugins/static.jssees, since it builds file paths viadecodeURIComponent(req.path())— normalization now runs before decoding, changing traversal-resistance characteristics for that plugin (likely a hardening, but currently untested; worth a dedicated test before relying on it).TypeErrorduring routing (previously it never mattered for relative URLs). A missing Host header does not throw — it falls back tolocalhost. Highest-severity item — recommend adding Host-header validation middleware before upgrading.OPTIONS *requests:req.getUrl().pathnamenow returns/*instead of*(a bare*can't be represented as a URL). Anything checkingreq.getUrl().pathname === '*'should switch toreq.url === '*'.Also changed (adjacent cleanup)
req.isSecure()now readsthis.socket.encryptedinstead ofthis.connection.encrypted(same swap inaudit.js/throttle.js). Not URL-parsing related, but feeds intogetUrl()'s protocol resolution — tests/code that stubreq.connectioninstead ofreq.socketwill silently misbehave.Action for consumers: grep for
.getUrl(,.href(,.getHref(,.path(,.getPath(,.query(,.getQuery(; update staleurl.Urltype declarations toURL; add Host-header validation; re-run tests (this tends to surface as silently wrong values, not crashes).