urlpattern
urlpattern copied to clipboard
pathnames starting with `./` immediately follow by a matching group can result in double-slash
Consider this new URLPattern({ pathname: './*', baseURL: self.location })
evaluated on a page at /index.html'. The resulting pathname is
//*` which is somewhat unexpected.
This occurs because the /
preceding the *
is treated as an implicit prefix. This causes the pathname encoder to see just /.
which is collapsed to /
. Then the /*
is appended to get //*
.
Authors can workaround this issue for this specific case one of two ways:
-
new URLPattern({ pathname: './{*}', baseURL: self.location })
; or -
new URLPattern({ pathname: '*', baseURL: self.location })
I don't have a good idea on how to fix this in the algorithm at the moment.