normalize-slashes
Normalize paths to by adding or removing beginning and/or end slashes.
Also, deduplicates extra slashes to a single slash and resolves ..
and .
.
Installation
npm i -g normalize-slashes
Usage
// remove start and end slashes by default // 'hello/world' // 'hello/world' // 'hello/world' // 'world' // normalize to have end slashes (remove start slashes)var opts = end: true // 'hello/world/' <- slash added // 'hello/world/' // 'hello/world/' // 'world/' // normalize to have start slashes (remove end slashes)var opts = start: true // '/hello/world' <- slash added // '/hello/world' // '/hello/world' // '/world' // normalize to have start and end slashesvar opts = start: true end: true // '/hello/world/' <- slashes added // '/hello/world/' // '/hello/world/' // '/world/'
License
MIT