Optional params not working.
Closed this issue · 5 comments
Seems like uniloc
doesn't support optional params.
Configuring this route/test/:name/:id/:fields?
, giving this error
Error: Unirouter Assertion Failed: Path `/test/:name/:id/:fields?` does not contain the `#` or `?` characters
Please suggest any alternative.
Totally open to incorporating a matcher that can do more. I've run into similar limitations. Any libraries that you have in mind that we should consider?
- https://www.npmjs.com/package/url-pattern
- https://www.npmjs.com/package/route-parser
- https://www.npmjs.com/package/route-pattern
url-pattern
is lightest of all, I think and used by a micro module https://github.com/dotcypress/micro-route
Is any library helpful?
Your thoughts, please.
Hey, sorry I managed to miss that you had replied! :( I'll make some time this weekend to consider the available libraries and integrate one.
Check it out, we now use: https://github.com/pillarjs/path-match
You can see your case covered here in the underlying library: https://github.com/pillarjs/path-to-regexp/blob/master/test.ts#L499