koa-normalize-path
Koa middleware that normalizes paths.
Notice: koa-normalize-path@2 supports koa@2; if you want to use this module with koa@1, please use koa-normalize-path@1.
Installation
npm install koa-normalize-path
API
const Koa = ;const app = ;app;
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 = ;const normalizePath = ; const app = ; app; app; app;
Important
When used together with koa-static it might be a good idea to set defer
to true
for koa-static
and false for koa-normalize-path
. This to avoid a potential problem that will result in an error being thrown stating the path is malicious if it starts with multiple slashes. https://github.com/koajs/send/issues/51
License
MIT