whatwg / urlpattern

URL Pattern Standard
https://urlpattern.spec.whatwg.org/
Other
157 stars 22 forks source link

Support ipv6 addresses in constructor string #113

Closed wanderview closed 3 years ago

wanderview commented 3 years ago

As pointed out in #110 its not possible to do new URLPattern("http://[::1]/"). Even if you properly escape the colons like new URLPattern("http://[\\:\\:1]/") it still throws.

Adding support for this turns out to not be too hard. The URL spec simply ignores colons inside [ ] brackets. We can do the same in URLPattern. Of course, for the hostname pattern to be valid the colon's will still need to be escaped.