Koa-router route matching problem

koa-router routing settings are as follows,

router.get("/user/:id")
router.get("/user/aaa")

cannot access / user/aaa, is parsed to the parameter "aaa";
when the following settings are set,

router.get("/user/aaa")
router.get("/user/:id")

can access / user/aaa normally.
how can I tell whether it is a parameter or a path?

Mar.18,2021

who defines first and matches first.


/ user/:id id is the dynamic parameter
/ user/aaa is the definition of the path, but it will be matched to

by / user/:id first.
Menu