prepend-slash
v1.0.1
Published
Sets a leading slash as the first character of a given string.
Downloads
1
Readme
prepend-slash
Sets a leading slash as the first character of a given string.
Install
$ npm install prepend-slash
Usage
var prependSlash = require('prepend-slash');
console.log(prependSlash('path/to')); // output: /path/to
console.log(prependSlash('/path/to')); // output: /path/to
console.log(prependSlash('')); // throws TypeError
console.log(prependSlash('', false)); // output: /
API
prependSlash(string, [strict=true])
string
Type: String
strict
Type: Boolean
Default: true
Set it false
to make it silent. It's useful if you're fine with '/' as a result.
Test
$ npm test
License
MIT © Purpose Industries