how to get matched route path
JerrysShan opened this issue · 4 comments
JerrysShan commented
if I register a router
router.on('/api/:id',(req,res)=>{
// how to get matched route path '/api/:id'
res.end('hello world');
})
ivan-tymoshenko commented
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
JerrysShan commented
@ivan-tymoshenko Thanks, but I want to get the register path that match the request path
ivan-tymoshenko commented
Then you should escape your parameter with encodeuricomponent function before inserting.
ivan-tymoshenko commented
@JerrysShan I'm closing this issue. Feel free to reopen it if you still have some questions.