Closed vlatkoodrljin closed 2 years ago
Hi, I have added an option for trailing slash redirect in v0.11.0 under the option redirectTrailingSlash
. Please try it when you have the time.
It works but it would be more useful and efficient to have option only for ignoring trailing slash if exists on router level. Same like we have in find-my-way router module.
Something like this:
const router = new Router({
ignoreTrailingSlash: true
});
const handler = function(ctx) {
ctx.body = "hello, foo";
};
// maps "/foo/" and "/foo" to `handler`
router.get("/foo", handler); or router.get("/foo/", handler);
What do you think?
Sorry, I misunderstand your request last weekend. I have added ignoreTrailingSlash
in v0.12.0.
It is useful sometimes not to return 404 if trailing slash exists but not explicitly in route pattern. What about adding ignoreTrailingSlash option while instancing for ignoring trailing slashes?