slash

Convert Windows backslash paths to slash paths

npm install slash
451 downloads in the last day
2 820 downloads in the last week
7 761 downloads in the last month

slash Build Status

Convert Windows backslash paths to slash paths: foo\\barfoo/bar

Forward-slash paths can be used in Windows as long as they're not extended-length paths and don't contain any non-ascii characters.

Install

Download the library manually or with a package-manager.

npm

npm install --save slash

Bower

bower install --save slash

Component

component install sindresorhus/slash

Example

Using Node.js:

var path = require('path');
var slash = require('slash');

var str = path.join('foo', 'bar');
console.log(str);
// Unix    => foo/bar
// Windows => foo\\bar

if (process.platform === 'win32') {
  str = slash(str);
}

console.log(str);
// Unix    => foo/bar
// Windows => foo/bar

API

slash(path)

Type: String

Accepts a Windows backslash path and returns a slash path.

License

MIT © Sindre Sorhus

npm loves you