path-normalize
TypeScript icon, indicating that this package has built-in type declarations

6.0.13 • Public • Published

path-normalize

Zero-dependency browser-oriented path.normalize.

Donate

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()
  }
})

LICENSE

Dependencies (0)

    Dev Dependencies (10)

    Package Sidebar

    Install

    npm i path-normalize

    Weekly Downloads

    2,891

    Version

    6.0.13

    License

    MIT

    Unpacked Size

    7.78 kB

    Total Files

    6

    Last publish

    Collaborators

    • zacanger