universal-router icon indicating copy to clipboard operation
universal-router copied to clipboard

Nested route snippet example not working

Open JoeGrasso opened this issue 7 years ago • 6 comments

How blessed difficult would it be to put a nested route in your starter kit. The snippet example you provide is too terse!

JoeGrasso avatar Aug 16 '17 16:08 JoeGrasso

Could you explain what exactly is not working or what behavior are you expect?

One more example: https://jsfiddle.net/frenzzy/8rm2y4jg/

frenzzy avatar Aug 17 '17 09:08 frenzzy

@frenzzy example doesn't work with [email protected] - can't select /posts or /posts/hello-world

mbme avatar Sep 20 '17 07:09 mbme

@mbme updated demo for v4: https://jsfiddle.net/frenzzy/8rm2y4jg/4/

frenzzy avatar Sep 20 '17 07:09 frenzzy

many thanks! was not clear to me that inner path now should be empty :)

mbme avatar Sep 20 '17 07:09 mbme

If you are using trailing slashes in your paths, then router will match urls only with trailing slashes, ie

path: '/posts'   // matches both "/posts" and "/posts/"
path: '/posts/'  // matches only "/posts/"
path: '/posts'  +  path: ''       =  path: '/posts'
path: '/posts'  +  path: '/'      =  path: '/posts/'
path: '/posts'  +  path: '/:id'   =  path: '/posts/:id'
path: '/posts'  +  path: '/:id/'  =  path: '/posts/:id/'

There is an example in README.md

Any suggestions how to make it cleaner for other people?

frenzzy avatar Sep 20 '17 07:09 frenzzy

Docs are clear enough, that was just me - I didn't notice README updated after release

Thanks for the great library!

mbme avatar Sep 20 '17 09:09 mbme