Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

express-normalizeurl

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

express-normalizeurl

URL normalisation for Express and Connect. Forked form @AntuanKhanna/express-url to serve as (almost) drop-in replacement and to maintain the unmaintained code.

  • 1.5.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
increased by100%
Maintainers
1
Weekly downloads
 
Created
Source

Express-NormalizeUrl

URL normalisation for Express and Connect. Forked from @AntuanKhanna/express-url to serve as an (almost) drop-in replacement (please see Middleware options for that matter) for an unmaintained project.

About

Taking care of

  • trailing slashes
  • repeated slashes
  • repeated question marks
  • repeated ampersands
  • repeated query strings
  • case sensitivity (does not affect queries by default)

Redirect example

//assuming default options (see Middleware options)
request:  //sLuG??param=val&&param2=VAL2
response: /slug/?param=val&param2=VAL2

Installation

$ npm install express-normalizeurl

Usage

As middelware

// Require module
// If you used express-url before, this is the only line you need to change
var expurl = require('express-normalizeurl');

// Process routes through middleware
app.use(expurl());

Middleware options

app.use(expurl({
    requestType: 'GET',
    redirectStatusCode: 302,
    lowercase: true,
    lowercaseQueries: false, // False by default, requires lowercase to be set to true to work. If you want 100% compatibility with express-url, when lowercase is true, this also needs to be set true
    trailingSlash: true,
    repeatedSlash: true,
    repeatedQuestionMark: true,
    repeatedAmpersand: true
}));

Tests

$ npm install
$ cd node_modules/express-normalizeurl
$ 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);

Keywords

FAQs

Package last updated on 24 Jul 2019

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc