1.0.1 • Published 10 years ago
prepend-slash v1.0.1
prepend-slash
Sets a leading slash as the first character of a given string.
Install
$ npm install prepend-slashUsage
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 testLicense
MIT © Purpose Industries