delvedor/find-my-way

how to get matched route path

JerrysShan opened this issue · 4 comments

if I register a router

router.on('/api/:id',(req,res)=>{
// how to get matched route path  '/api/:id'

res.end('hello world');
})

Hi, you should use another escaping colon char when you register a route.

If you just want a path containing a colon without declaring a parameter, use a double colon. For example, /name::customVerb will be interpreted as /name:customVerb

https://github.com/delvedor/find-my-way#match-order

@ivan-tymoshenko Thanks, but I want to get the register path that match the request path

Then you should escape your parameter with encodeuricomponent function before inserting.

@JerrysShan I'm closing this issue. Feel free to reopen it if you still have some questions.