Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

slash

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

slash - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

2

package.json
{
"name": "slash",
"version": "0.1.0",
"version": "0.1.1",
"description": "Convert Windows backslash paths to slash paths",

@@ -5,0 +5,0 @@ "keywords": [

# slash [![Build Status](https://secure.travis-ci.org/sindresorhus/slash.png?branch=master)](http://travis-ci.org/sindresorhus/slash)
Convert Windows backslash paths to slash paths.
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 it's not an extended-length path and it doesn't contain Unicode.
[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.

@@ -10,7 +10,27 @@

Install with [npm](https://npmjs.org): `npm install --save slash`
Download the library [manually](https://github.com/sindresorhus/slash/releases) or with a package-manager.
#### [npm](https://npmjs.org/package/slash)
```
npm install --save slash
```
#### [Bower](http://bower.io)
```
bower install --save slash
```
#### [Component](https://github.com/component/component)
```
component install sindresorhus/slash
```
## Example
Using Node.js:
```js

@@ -22,9 +42,12 @@ var path = require('path');

console.log(str);
//=> foo\\bar
// Unix => foo/bar
// Windows => foo\\bar
if (process.platform === 'win32') {
str = slash(str);
console.log(str);
//=> foo/bar
str = slash(str);
}
console.log(str);
// Unix => foo/bar
// Windows => foo/bar
```

@@ -44,2 +67,2 @@

MIT License • © [Sindre Sorhus](http://sindresorhus.com)
MIT © [Sindre Sorhus](http://sindresorhus.com)

@@ -1,14 +0,20 @@

'use strict';
module.exports = function (str) {
// Windows converts slash paths to backslashes if it's not an
// extended-length path and doesn't contain any Unicode
// http://msdn.microsoft.com/en-us/library/aa365247.aspx
var isExtendedLengthPath = /^\\\\\?\\/.test(str);
var hasUnicode = /[^\x00-\x80]+/.test(str);
(function () {
'use strict';
if (isExtendedLengthPath || hasUnicode) {
return str;
function slash(str) {
var isExtendedLengthPath = /^\\\\\?\\/.test(str);
var hasNonAscii = /[^\x00-\x80]+/.test(str);
if (isExtendedLengthPath || hasNonAscii) {
return str;
}
return str.replace(/\\/g, '/');
}
return str.replace(/\\/g, '/');
};
if (typeof module !== 'undefined' && module.exports) {
module.exports = slash;
} else {
window.slash = slash;
}
})();
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc