🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

path-normalize

Package Overview
Dependencies
Maintainers
1
Versions
67
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

path-normalize

Zero-dependency browser-oriented path.normalize

2.1.0
Source
npm
Version published
Weekly downloads
13K
22.5%
Maintainers
1
Weekly downloads
 
Created
Source

path-normalize

Zero-dependency browser-oriented path.normalize.

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 and strips directory traversals (../).

Portions of this code are heavily based on code in Node.

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

Keywords

normalize

FAQs

Package last updated on 22 Apr 2018

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