1.0.1 • Published 9 years ago

prepend-slash v1.0.1

Weekly downloads
4
License
MIT
Repository
-
Last release
9 years ago

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