Skip to content

Latest commit

 

History

History
50 lines (31 loc) · 1.24 KB

.verb.md

File metadata and controls

50 lines (31 loc) · 1.24 KB

Usage

const normalize = require('{%= name %}');

console.log(normalize('\\foo\\bar\\baz\\')); 
//=> '/foo/bar/baz'

win32 namespaces

console.log(normalize('\\\\?\\UNC\\Server01\\user\\docs\\Letter.txt')); 
//=> '//?/UNC/Server01/user/docs/Letter.txt'

console.log(normalize('\\\\.\\CdRomX')); 
//=> '//./CdRomX'

Consecutive slashes

Condenses multiple consecutive forward slashes (except for leading slashes in win32 namespaces) to a single slash.

console.log(normalize('.//foo//bar///////baz/')); 
//=> './foo/bar/baz'

Trailing slashes

By default trailing slashes are removed. Pass false as the last argument to disable this behavior and keep trailing slashes:

console.log(normalize('foo\\bar\\baz\\', false)); //=> 'foo/bar/baz/'
console.log(normalize('./foo/bar/baz/', false)); //=> './foo/bar/baz/'

Release history

v3.0

No breaking changes in this release.

  • a check was added to ensure that win32 namespaces are handled properly by win32 path.parse() after a path has been normalized by this library.
  • a minor optimization was made to simplify how the trailing separator was handled