Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

path-normalize

3.0.2 • Public • Published

path-normalize

Zero-dependency browser-oriented path.normalize.

npm version CircleCI codecov

path-normalize is different from normalize-path; normalize-path only handles slashes, while this lib is a browser-focused version of the POSIX path.normalize in Node.

path-normalize also differs from Node's path.normalize. path-normalize handles uri-encoded strings.

Most of this library is directly from Node's source.

Installation

npm i path-normalize

Usage

const normalize = require('path-normalize')
const normal = (somePath) => normalize(somePath)

Slightly more real-world example:

import normalize from 'path-normalize'
 
// imaginary client-side router api
router.route('/foo/*', (pathname) => {
  const normalized = normalize(pathname)
  if (normalized !== pathname) {
    router.redirect(normalized)
  } else {
    renderFoo()
  }
})

See also: react-router-path-normalize.

License

MIT

install

npm i path-normalize

Downloadsweekly downloads

794

version

3.0.2

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability