urlpattern icon indicating copy to clipboard operation
urlpattern copied to clipboard

Cannot capture default port in a named group

Open rotu opened this issue 5 months ago • 10 comments

What is the issue with the URL Pattern Standard?

Using a :<name> token to capture the port of a URL fails if the URL is using the default port for that protocol (either explicitly or implicitly). Tested in Chrome.

// false!?!?
new URLPattern('http://example.com::port').test('http://example.com:80')

// works if you use a non-standard port
new URLPattern('http://example.com::port').test('http://example.com:81') 
// works if you use an asterisk instead of a name token
new URLPattern('http://example.com:*').test('http://example.com:80')

rotu avatar Aug 30 '24 00:08 rotu