-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
URLPattern object literal syntax results seem unintuitive #260
Comments
See WICG/nav-speculation#260 for why the previous version was wrong.
It feels like your integration needs a way to signal not to use the base URL. |
One approach would be adding "where": {"href_matches": {"protocol": "https"}, "relative_to": null} It certainly makes this possible, but it's regrettably that either way we need to force you to choose rather than the syntax making the right choice natural. (And having different defaults for object and string syntax seems...inconsistent. Even though I suspect it would yield the "right answer" more often.) |
Due to whatwg/urlpattern#198, |
Continuing discussion from an internal thread. This is halfway between a
URLPattern
issue, and a platform-integration-with-URLPattern
issue. E.g., I think we'd see similar things come up if we attempted to integrate URLPattern into other headers, or use it to replace the ad-hoc patterns we see in existing headers like CSP. So I'd love @wanderview's take.In https://github.com/domenic/blog.domenic.me/blob/1a367f722a6571879aa5a92faaf5a32f657ffd60/src/js/preload.mjs#L22 I did
thinking this would mean, any link which matches the
https
protocol. I.e., it would be equivalent tonew URLPattern({ protocol: "https" })
.Instead, it's equivalent to
new URLPattern({ protocol: "https", baseURL: document.baseURI })
. Since the base URL already hashttps:
as its protocol, this basically means I've constructed aURLPattern
that only matches the current page.Trying to fix this by expanding the pattern to
{ protocol: "https", pathname: "*" }
kind of works... but then it doesn't match anything with a non-empty query string, or fragment. You end up needingI don't know what a good solution is here. Here are some ideas, none of which are very satisfactory:
"*"
instead of drawing from the base URL.){ protocol: "https", pathname: "**" }
maybe?{ protocol: "https", pathname: "*" }
automatically getsearch: "*"
andhash: "*"
.I am pretty convinced that in the current form, the object literal URLPatterns are somewhat useless for most people, because they'll almost always need to fill in a bunch of
"*"
entries. I think this is an echo of the problem in #259 and the problem we've noted before where/*\\?*#*
is a pretty confusing way of saying "everything on this origin". It's just more painful for object literals since they're more verbose.The text was updated successfully, but these errors were encountered: