Novices Performing Miracles
Have ideas to improve npm?Join in the discussion! »

koa-remove-trailing-slashes

2.0.1 • Public • Published

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.

Build Status Coverage Status npm

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 to true.
  • chained - If the middleware should continue modifying the url if it detects that a redirect already have been performed. Defaults to true.

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

Install

npm i koa-remove-trailing-slashes

DownloadsWeekly Downloads

526

Version

2.0.1

License

MIT

Unpacked Size

5.08 kB

Total Files

4

Last publish

Collaborators

  • avatar
  • avatar