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

Support named wildcards (PR)

Open randomdevpete opened this issue 7 years ago • 2 comments

Firstly - I have already created a pull request for this feature, I realise the contributing guidelines say not to do this, but in my case I needed the feature anyway and am using that build in my routing library: https://github.com/downplay/jarl-react

So, I will not be too concerned if the pull request is ultimately declined, as I will carry on using my fork anyway, but I am opening this issue as it would still be nice to see the functionality in the main package, and am happy to discuss any changes to make this happen. I am also aware that this feature has been mentioned elsewhere and is probably desirable (but maybe you were thinking of different syntax).

The pull request is here: https://github.com/snd/url-pattern/pull/44

The syntax I have implemented for named wildcards is: /*:path which will capture everything into path instead of _. I chose this syntax because it is unambiguous compared to existing syntax and did not break any existing tests, and I feel the meaning is instantly clear when reading the syntax.

I've added a complete set of tests for the syntax, BUT I did not update any documentation - if discussion is positive then I am happy to also update the docs and add to the pull request.

I look forward to feedback!

randomdevpete avatar Jan 06 '18 10:01 randomdevpete

thanks. this enhancement is reasonable and the implementation is well thought out. i'll include it in a new release soon. very busy working on other things atm

snd avatar Jan 22 '18 17:01 snd

I've pushed a documentation update now for the new syntax. Will be great to see this merged.

randomdevpete avatar Jan 28 '18 13:01 randomdevpete