koa-remove-trailing-slashes
v2.0.3
Published
Koa middleware that makes sure all requests does not have trailing slashes
Downloads
1,126
Readme
koa-remove-trailing-slashes
Koa middleware that removes trailing slashes on paths.
Notice: koa-remove-trailing-slashes@2 supports koa@2; if you want to use this module with koa@1, please use koa-remove-trailing-slashes@1.
Installation
npm install koa-remove-trailing-slashes
API
const Koa = require('koa');
const app = Koa();
app.use(require('koa-remove-trailing-slashes')(opts));
opts
options object.
Options
defer
- If true, serves after yield next, allowing any downstream middleware to respond first. Defaults totrue
.chained
- If the middleware should continue modifying the url if it detects that a redirect already have been performed. Defaults totrue
.
Example
const Koa = require('koa');
const removeTrailingSlashes = require('koa-remove-trailing-slashes');
const app = new Koa();
app.use(removeTrailingSlashes());
app.use(ctx => {
ctx.body = 'Hello World';
});
app.listen(3000);
License
MIT