fix(node:url): WHATWG IPv4 host canonicalization (hostname setter + domainToASCII) (#3056, #3059)#3529
Merged
Merged
Conversation
added 2 commits
May 31, 2026 07:14
…+ domainToASCII Perry's URL uses a custom hostname parser that only runs IDNA, so it never applied the WHATWG numeric/IPv4-shorthand host parser. Borrow the url crate's WHATWG host parser as a post-step: - hostname setter (#3056): Web-IDL-stringify the RHS then canonicalize (123 -> 0.0.0.123, 0x7f.1 -> 127.0.0.1); out-of-range numeric leaves the host unchanged, matching Node. - domainToASCII/domainToUnicode (#3059): stringify the arg and run the same WHATWG host parsing (numeric -> IPv4, IDN -> punycode/Unicode, invalid -> ''). Ordinary + IDN hostnames are unchanged.
…56-3059 # Conflicts: # crates/perry-codegen/src/expr/url_main.rs # crates/perry-runtime/src/url/mod.rs
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.
Closes #3056
Closes #3059
Adds
whatwg_canonicalize_host(reparseshttp://<host>/via theurlcrate) so numeric/IPv4-shorthand hosts canonicalize per WHATWG (u.hostname=123→0.0.0.123;url.domainToASCII(123)→0.0.0.123) while ordinary hostnames and punycode IDN labels are unchanged. Gap test + existing URL parity tests byte-identical to Node. Verified under default auto-optimize compile.