prepend-slash

v1.0.1
Sets a leading slash as the first character of a given string.
prepend leading slash

prepend-slash

Build Status Code Climate Coverage Status

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

npm i prepend-slash

Metadata

  • MIT
  • Whatever
  • ruffle1986
  • released 8/31/2015

Downloads

Maintainers