Open posva opened 3 years ago
I think this one is working as intended. Its behavior inherited from path-to-regexp.
Also, its unclear to me how to implement this in the general sense. Consider that a repeated modifier might be applied to something without a prefix; e.g. foo{:g}+bar
. Also consider that :g
is a non-greedy match meaning that "each group" would match as few characters as possible. So if we split this into an array, then matching against foobazbar
would result in a g
array where each letter is a separate array index like ['b', 'a', 'z']
. This doesn't seem expected or desirable to me.
I think I would prefer to leave it to external code to do the splitting in a way that made sense to them for now. If it becomes super common then maybe we could adopt and option to auto-split on a given divider or something in the future.
I see, to me, repeatable groups can only be between /
e.g: /:id+
but never /a-:id+-b
, so I never faced anything like foo:g+bar
. Semantically speaking I do expect a list for a repeatable group though but I think that's maybe only from the router perspective. So it would make sense to keep this behavior in the context of a pattern
To me this reinforces the need of https://github.com/WICG/urlpattern/issues/147 in order to apply custom transformations to groups
Hello, I'm testing out the URLPattern in Chrome canary against the test suite I use for Vue Router and I found that repeated groups (
/:id+
and/:id*
) are not put into an array when extracted:This will output:
While it's easy to make this work by calling
.split('/')
, I thinkid
should be an array because its modifier is a repeatable one.