You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When creating a pattern like new URLPattern('/:id/static/:tags*'), there is no way of knowing what groups the pattern has (id and tags) nor their nature (optional, repeatable).
I would consider this useful for error reporting and inspecting purposes. For example, if a user tries to build a path by passing an object of groups to the pattern (which I believe must be another issue somewhere but doing pattern.buildURL({ id: 2 }) -> /2/static), we can check any missing params and give the user better debugging information.
It can also be used to build UI around URL builders or checkers. For instance, I rely on this on the Vue Devtools.
Overall, this information would be very useful to extend the URLPattern API and would avoid hacks with Regexps to parse existing groups (which would partially defeat the purpose of URLPattern)
When creating a pattern like
new URLPattern('/:id/static/:tags*')
, there is no way of knowing what groups the pattern has (id and tags) nor their nature (optional, repeatable).I propose a way of getting these groups:
It's also worth noting this can be typed in TS too with string literals.
The text was updated successfully, but these errors were encountered: