Skip to content

Fix unexpected stripping of default port in port canonicalization#286

Open
sisidovski wants to merge 1 commit into
whatwg:mainfrom
sisidovski:issue285
Open

Fix unexpected stripping of default port in port canonicalization#286
sisidovski wants to merge 1 commit into
whatwg:mainfrom
sisidovski:issue285

Conversation

@sisidovski

@sisidovski sisidovski commented Jun 12, 2026

Copy link
Copy Markdown
Collaborator

This prevents the https default port (443) from being replaced with the empty string in canonicalize a port. The algorithm creates an https dummy URL (https://dummy.invalid/), any partial substring that happens to match 443 (e.g., the "443" in new URLPattern({ port: "*443" })) gets interpreted as the default port for https and is wrongly stripped to the empty string.

This modifies the canonicalize a port algorithm so that when it is invoked without an explicit protocolValue, it sets the dummy URL's scheme to the empty string rather than leaving it as "https".

(See WHATWG Working Mode: Changes for more details.)

Fixes #285.


Preview | Diff

@sisidovski sisidovski requested a review from annevk June 12, 2026 04:31
@annevk

annevk commented Jun 12, 2026

Copy link
Copy Markdown
Member

This is a normative change so we should use the PR template, no?

@shannonbooth

shannonbooth commented Jun 12, 2026

Copy link
Copy Markdown
Member

I went digging, apparently the test for this has already been merged: web-platform-tests/wpt@23aac92

edit: and FWIW this MR gets that test working for my implementation

@sisidovski

Copy link
Copy Markdown
Collaborator Author

Updated the description to use PR template.

Similar to #272, this is more like a spec bug after 46c30fd. We've confirmed that both Safari and Firefox have already implemented the behavior consistent with this change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Encoding for port removes "443" in substrings of patterns

3 participants