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'
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/'
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