navi
navi copied to clipboard
routing with optional parameters
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
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: