prepend-slash

1.0.1 • Public • Published

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

Readme

Keywords

Package Sidebar

Install

npm i prepend-slash

Weekly Downloads

1

Version

1.0.1

License

MIT

Last publish

Collaborators

  • ruffle1986