-
Notifications
You must be signed in to change notification settings - Fork 36
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
All our examples using /*\\?* URL pattern syntax break for fragment links #259
Comments
We could (and maybe we do?) skip the fragment part since it clearly has no effect for prefetching at least. (I suppose it can for prerendering, though, now that I think about it.) That said, even |
What is the goal of the pattern? To match URLs like the current document's URL, but with any path, query, or fragment? In that case I find it easier to read:
|
Yep, that's the goal. The issue, I think, is that it's non-obvious in our experience, that I think there's a sort of intuition that if you don't care about the pathname, then of course you don't want to match the current base URL's search and hash. Nobody would want to carry over the search and hash from there. And you expect the API to understand this, somehow. Basically, I think the implicit defaulting of |
Right, I think giving more control/visibility of the application of the base URL would help.
I think some of this comes from doing And if we changed URLPattern to auto-wildcard search/hash if you wildcard pathname, then that would prevent any way to override the pathname but continue to inherit the search/hash. It feels like that should be possible, even if its a niche or rare use case. |
The reason I think implicit base URL is correct is that:
Implicit base URL only for relative URLs would be another option, but it kinda adds a third behavior to the two that URLPattern already defines, which is also a little awkward. |
Today @KenjiBaheux and I were working on some slide decks explaining how to set up document rules for your site. We were continually caught out by this. We had to update the presentation in the following ways:
Here is my best proposal: When constructing a
If you want to inherit those components from the base URL instead, then you can specify an option, e.g.
WDYT? |
Is there any reason your integration of base URL and the URLPattern constructor have to match? For example, when I was looking at integration with service workers I was going to use URLPattern syntax for the pathname, but apply the baseURL to it separately aligning with service worker rules. That being said, I don't have strong objections if you want to pursue this. I don't personally have time to make the changes to URLPattern, though. |
I'd love to learn more about alternate models here. I can see how this would work if you had a single-component (i.e. pathname-only) URLPattern: you could extract out the pathname and match it against the URLPattern's pathname. But we need something more generic for our case. We need to support patterns that restrict on query params (e.g., prefetch If you think inventing such a combination method and using it only in this spec is reasonable though, let us know, and we can put that option on the table.
Understood! I'm currently trying to figure out where fixing this annoyance falls in our teams' priorities. If it's high enough, then we'd be happy to do the work of updating the spec, tests, and Chromium implementation, including engaging with the URLPattern repo and its community to make sure we're building the right thing. In either case, thanks very much to you for helping us understand the problem space over in this repo, before we take that step. |
Looking at this again, I think this would have to decompose into two possible changes:
The second isn't sufficient because the first actually emits empty strings, not absent components. The latter is the one where I think @wanderview is asking for an opt-out, along the lines of a I've agreed to add a UseCounter to look at what this would affect, but want to make sure we're on the same page on the particulars of what I'm to measure. |
We've fixed the underlying issue. We need to update all the docs to use the simpler, more-intuitive syntax now :) |
Now that URL patterns are better, as of whatwg/urlpattern@ed205a4, we no longer need the ?* or ?*#* syntax. Fixes #259.
Now that URL patterns are better, as of whatwg/urlpattern@ed205a4, we no longer need the ?* or ?*#* syntax. Fixes #259.
E.g.
We should, I guess, be recommending
/*\\?*#*
??cc @wanderview in case there's anything better we can do at the URLPattern layer... Maybe some sort of syntax like
/**
would be helpful?The text was updated successfully, but these errors were encountered: