normalize-pathname

normalizes any pathname to one leading slash and no trailing slash

npm install normalize-pathname
3 downloads in the last week
29 downloads in the last month

normalize-pathname

Normalizes any pathname to the same format: one leading slash, no trailing slash.

install

npm install normalize-pathname

usage

var normalizePathname = require('normalize-pathname');
console.log(normalizePathname('wibblebong/wollomombi/'));
// -> '/wibblebong/wollomombi'

examples

/one/two/ -> /one/two
one/two   -> /one/two
one/two/  -> /one/two
one       -> /one
/one/     -> /one
one/      -> /one
/         -> (empty string)
npm loves you