url-pattern icon indicating copy to clipboard operation
url-pattern copied to clipboard

how to create pattern for unlimited amount of url parameters?

Open zilahir opened this issue 5 years ago • 0 comments

It's probably on me, but I was unable to create a pattern for url's like this:

<url>/present/tag1/tag2/tag3/[...tagN]

the <url>/present is a const, the tags are coming at the end of it.

This is what Ive been trying with:

new UrlPattern(/^\/present\/(.*)$/);

but then result is:

["1-lorem/5-ipsum"]

which is an array, with a single item.

Now i could split it by / but then the usage of url-pattern becomes quite unnecessary, so I'd rather solve it using the corerct way.

What i am aiming for is something like this:

["1-lorem", "2-ipsum"]

Any help is appreciated.

zilahir avatar Oct 20 '20 13:10 zilahir