slasher

Prefix a path with leading slash

slasher

Prefix a path with leading slash

npm install slasher --save
var slash = require('slasher');
 
// Strings 
var pathname = 'some/path/to/something';
var pathname = slash(pathname); // OUTPUTS: '/some/path/to/something' 
 
// Objects 
var paths = {
  'some/route': 'index.html'
};
var paths = slash(paths);
 
// OUTPUTS: 
{
  '/some/route': '/index.html'
}
  • data - a string or object to slash
  • options - OPTIONAL. Set key or value to false to not add a slash to those values in an object
npm install
npm test