navi icon indicating copy to clipboard operation
navi copied to clipboard

routing with optional parameters

Open chinds185a opened this issue 5 years ago • 1 comments

Following on from this issue #85 could you point me in the right direction where this work might need to be done?

My previous routing logic relied on react-router supporting optional params and not only splitting on a / i.e. my URL could have optional param of .amp

In react-router this works: /:language(${languageRegex})/page/:id(${idRegex}):amp(.amp)?

In navi id & amp get combined into a single param and thus never match correctly

chinds185a avatar Jul 28 '19 19:07 chinds185a

So basically the way matching works in Navi, is that the remaining part of the route is passed to a mount(), which splits it along the first / character, ignores the second half, and tries to match the first half with each of its supplied patterns.

To support more complex patterns, you'd need to modify this behavior. Here's a few relevant sections of code:

jamesknelson avatar Jul 29 '19 03:07 jamesknelson