const router = new KoaRouter({
prefix: "/articles"
})
router.get("/:id/author", articles.author)
router.get("/:id/info", articles.info)
router.get("/", articles.index)
module.exports = router
/1/author 匹配成功,返回内容正常
/1/author/ 匹配失败,跳到首页
1
Arrowing 2017-01-20 17:07:22 +08:00
自己做个中间件吧,网上有一个做好的。
https://www.npmjs.com/package/koa-no-trailing-slash |
2
magicdawn 2017-01-25 22:09:13 +08:00 1
try https://github.com/magicdawn/impress-router
options.strict 默认 false, trailing slash 可选, 写成 true, 严格匹配 see path-to-regexp 文档 https://github.com/pillarjs/path-to-regexp#usage |