Nested Dynamic Routes Handling
Ok I'm out of ideas:
Wanted Routing:
/us/:department -> departmentHandler
/us/:department/ -> departmentHandler
/us/:department/:class -> classHandler
/us/:department/:class/ -> classHandler
/us/:department/:class/:subcategory -> subcategoryHandler
/us/:department/:class/:subcategory/ -> subcategoryHandler
Setup:
<Route path='/us' handler={require('./views/Handler')}>
<Route path='/us/:department' handler={require('./Department')}></Route>
<Route path='/us/:department/:class' handler={require('./Class')}></Route>
<Route path='/us/:department/:class/:category' handler={require('./Category')}></Route>
</Route>
However, as soon as I hit any route with a trailing slash, it 404s or Errors. Tried adding ? and ?: before and after every / but I never came to my wanted routing.
What am I doing wrong?
This works for me the way you described:
<Route path='/us' handler={..}>
<Route path='/us/:department/?' handler={..}></Route>
<Route path='/us/:department/:class/?' handler={..}></Route>
<Route path='/us/:department/:class/:category/?' handler={..}></Route>
</Route>
hmm, not for me. My URL changes to
http://localhost:8080/us/:department/:class
as soon as I hit http://localhost:8080/us/men/anything/. (Notice the slash at the end)
Ok nevermind... looks like a caching issue. It actually works. Thanks man! This bugged me for hours! Can't thank you enough!
I know the pain when the browser starts working against you :smile: . Glad to have helped