Need private packages and team management tools?Check out npm Teams »

express-url

1.4.0 • Public • Published

express-url

URL normalisation for Express and Connect

About

Taking care of

  • trailing slashes
  • repeated slashes
  • repeated question marks
  • repeated ampersands
  • repeated query strings
  • case sensitivity

Redirect example

request:  //sLuG??param=val&&param2=val2
response: /slug/?param=val&param2=val2

Installation

$ npm install express-url

Usage

As middelware

// Require module
var expurl = require('express-url');
 
// Process routes through middleware
app.use(expurl());

Middelware options

app.use(expurl({
    requestType: 'GET',
    redirectStatusCode: 302,
    lowercase: true,
    trailingSlash: true,
    repetedSlash: true,
    repeatedQuestionMark: true,
    repeatedAmpersand: true
}));

Tests

$ npm install
cd node_modules/express-url
$ npm test

Recommendations

  • do not serve static files with node directly
  • use case sensitive and strict routing
app.set('case sensitive routing', true);
app.set('strict routing', true);

Install

npm i express-url

DownloadsWeekly Downloads

1

Version

1.4.0

License

MIT

Last publish

Collaborators

  • avatar