koa-sanitize-uri
Important note: v1.0.0 is now compliant with koa@2. If you use koa < 2, install koa-sanitize-uri 0.1.x
Purpose
koa-sanitize-uri is a KOA middleware to sanitize request uri.
Request URI are checked. If they have a bad format, the middleware throw a redirect to the good uri with a 301 status (by default).
It's basically a good practice to keep consistant with URI and have only one URI per page content. It's aim is to avoid duplicate content (same content on 2 URI).
Read the CHANGELOG
Usage
;; const app= ;app; // ... app;
Options
All options at once:
app;
Ignore paths
You can give the middleware an option to ignore file or paths matching regex.
Example with one regex:
app;
Example with multi regex:
app;
Custom redirection status
app;
Sanitize options
You can pass all the sanitizer options with the key sanitize`
Developer
Installing dev dependencies, you can edit the package source. Then run:
npm run dev-compile
for babel transpilationnpm run dev-check
for eslint check