koa-remove-trailing-slashes

2.0.3 • 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

Package Sidebar

Install

npm i koa-remove-trailing-slashes

Weekly Downloads

310

Version

2.0.3

License

MIT

Unpacked Size

5.41 kB

Total Files

4

Last publish

Collaborators

  • dlmr
  • pakerstrand
  • ptrkmrkt
  • stale.pettersen.schibsted