Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sindresorhus/slash
Convert Windows backslash paths to slash paths
https://github.com/sindresorhus/slash
Last synced: about 8 hours ago
JSON representation
Convert Windows backslash paths to slash paths
- Host: GitHub
- URL: https://github.com/sindresorhus/slash
- Owner: sindresorhus
- License: mit
- Created: 2013-07-18T23:26:17.000Z (over 11 years ago)
- Default Branch: main
- Last Pushed: 2023-05-09T17:07:05.000Z (over 1 year ago)
- Last Synced: 2024-12-06T00:04:49.517Z (7 days ago)
- Language: JavaScript
- Homepage:
- Size: 26.4 KB
- Stars: 328
- Watchers: 17
- Forks: 51
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- Funding: .github/funding.yml
- License: license
- Security: .github/security.md
Awesome Lists containing this project
- awesome-nodejs - slash - 将 Windows 反斜杠路径转换为斜杠路径。![](https://img.shields.io/github/stars/sindresorhus/slash.svg?style=social&label=Star) (GIT 仓库 / 文件系统)
- awesome-star-libs - sindresorhus / slash
README
# slash
> Convert Windows backslash paths to slash paths: `foo\\bar` ➔ `foo/bar`
[Forward-slash paths can be used in Windows](http://superuser.com/a/176395/6877) as long as they're not extended-length paths.
This was created since the `path` methods in Node.js outputs `\\` paths on Windows.
## Install
```sh
npm install slash
```## Usage
```js
import path from 'node:path';
import slash from 'slash';const string = path.join('foo', 'bar');
// Unix => foo/bar
// Windows => foo\\barslash(string);
// Unix => foo/bar
// Windows => foo/bar
```## API
### slash(path)
Type: `string`
Accepts a Windows backslash path and returns a path with forward slashes.