You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
890 B

4 years ago
  1. # slash [![Build Status](https://travis-ci.org/sindresorhus/slash.svg?branch=master)](https://travis-ci.org/sindresorhus/slash)
  2. > Convert Windows backslash paths to slash paths: `foo\\bar` ➔ `foo/bar`
  3. [Forward-slash paths can be used in Windows](http://superuser.com/a/176395/6877) as long as they're not extended-length paths and don't contain any non-ascii characters.
  4. This was created since the `path` methods in Node outputs `\\` paths on Windows.
  5. ## Install
  6. ```sh
  7. $ npm install --save slash
  8. ```
  9. ## Usage
  10. ```js
  11. var path = require('path');
  12. var slash = require('slash');
  13. var str = path.join('foo', 'bar');
  14. // Unix => foo/bar
  15. // Windows => foo\\bar
  16. slash(str);
  17. // Unix => foo/bar
  18. // Windows => foo/bar
  19. ```
  20. ## API
  21. ### slash(path)
  22. Type: `string`
  23. Accepts a Windows backslash path and returns a slash path.
  24. ## License
  25. MIT © [Sindre Sorhus](http://sindresorhus.com)