unjs/rou3

Mixing specific and generic route params

Closed this issue · 1 comments

Environment

"radix3": "1.1.2"

Reproduction

https://stackblitz.com/edit/stackblitz-starters-awjduj?file=index.js

Describe the bug

i have route with generic entity handler
/api/:entity/:id
and route with specific entity id handler
/api/:entity/123

and it works well

but when route handler for specific entity present in router
/api/posts/:id/comments

router.lookup no longer returns generic route for this entity by paths like this /api/posts/312

it just returns nothing because in lookup function it sees static node by section name and tries to find route only inside this node

Additional context

image

Logs

No response

pi0 commented

Thanks for report and reproduction. I have made a rewrite of this library in #107 and next version will correctly handle this.

Updated sandbox with rou3: https://stackblitz.com/edit/stackblitz-starters-6na6gb?file=index.js