Sign In

koa-consistent-urls

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

koa-consistent-urls

Redirect inconsistent urls middleware for koa

latest
Source
npmnpm
Version
1.0.3
Version published
Maintainers
1
Created
Source

Koa Redirect Inconsistent

Redirect inconsistent urls middleware for koa.

  • www vs non-www.
  • Trailing slash vs no trailing slash.

Example

var consistentUrls = require('koa-consistent-urls')
var Koa = require('koa')

var app = new Koa()
app.use(consistentUrls({
  www: false,
  trailingSlash: false,
}))

API

app.use(require('koa-consistent-urls')(options))

Options are:

www

Whether or not to prepend the hostname with www.. Fix & redirect if the request url doesn't match.

true: Force www. on the hostname.

false: Remove www. from hostname.

Default: false.

trailingSlash

Whether or not to append a trailing slash (/) on the pathname. Fix & redirect if the request url doesn't match.

true: Force trailing slash (/) on the pathname.

false: Remove trailing slash (/) from pathname.

Default: false.

Tests

TODO. Feel free to PR.

FAQs

Package last updated on 16 Feb 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts