Socket
Book a DemoInstallSign in
Socket

prepend-slash

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

prepend-slash

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

latest
npmnpm
Version
1.0.1
Version published
Maintainers
1
Created
Source

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

Keywords

prepend

FAQs

Package last updated on 31 Aug 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts