diff options
Diffstat (limited to 'node_modules/slash')
| -rw-r--r-- | node_modules/slash/index.d.ts | 23 | ||||
| -rw-r--r-- | node_modules/slash/index.js | 14 | ||||
| -rw-r--r-- | node_modules/slash/license | 2 | ||||
| -rw-r--r-- | node_modules/slash/package.json | 23 | ||||
| -rw-r--r-- | node_modules/slash/readme.md | 28 |
5 files changed, 36 insertions, 54 deletions
diff --git a/node_modules/slash/index.d.ts b/node_modules/slash/index.d.ts deleted file mode 100644 index 692c7fda..00000000 --- a/node_modules/slash/index.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** -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. - -@param path - A Windows backslash path. -@returns A path with forward slashes. - -@example -``` -import path from 'node:path'; -import slash from 'slash'; - -const string = path.join('foo', 'bar'); -// Unix => foo/bar -// Windows => foo\\bar - -slash(string); -// Unix => foo/bar -// Windows => foo/bar -``` -*/ -export default function slash(path: string): string; diff --git a/node_modules/slash/index.js b/node_modules/slash/index.js index 1b7ee1ed..75d72501 100644 --- a/node_modules/slash/index.js +++ b/node_modules/slash/index.js @@ -1,9 +1,11 @@ -export default function slash(path) { - const isExtendedLengthPath = path.startsWith('\\\\?\\'); +'use strict'; +module.exports = input => { + const isExtendedLengthPath = /^\\\\\?\\/.test(input); + const hasNonAscii = /[^\u0000-\u0080]+/.test(input); // eslint-disable-line no-control-regex - if (isExtendedLengthPath) { - return path; + if (isExtendedLengthPath || hasNonAscii) { + return input; } - return path.replace(/\\/g, '/'); -} + return input.replace(/\\/g, '/'); +}; diff --git a/node_modules/slash/license b/node_modules/slash/license index fa7ceba3..e7af2f77 100644 --- a/node_modules/slash/license +++ b/node_modules/slash/license @@ -1,6 +1,6 @@ MIT License -Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com) +Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: diff --git a/node_modules/slash/package.json b/node_modules/slash/package.json index a0f507c9..1e360070 100644 --- a/node_modules/slash/package.json +++ b/node_modules/slash/package.json @@ -1,39 +1,34 @@ { "name": "slash", - "version": "5.1.0", + "version": "2.0.0", "description": "Convert Windows backslash paths to slash paths", "license": "MIT", "repository": "sindresorhus/slash", - "funding": "https://github.com/sponsors/sindresorhus", "author": { "name": "Sindre Sorhus", "email": "sindresorhus@gmail.com", - "url": "https://sindresorhus.com" + "url": "sindresorhus.com" }, - "type": "module", - "exports": "./index.js", - "types": "./index.d.ts", "engines": { - "node": ">=14.16" + "node": ">=6" }, "scripts": { - "test": "xo && ava && tsd" + "test": "xo && ava" }, "files": [ - "index.js", - "index.d.ts" + "index.js" ], "keywords": [ "path", "seperator", + "sep", "slash", "backslash", "windows", - "convert" + "win" ], "devDependencies": { - "ava": "^5.2.0", - "tsd": "^0.28.1", - "xo": "^0.54.2" + "ava": "*", + "xo": "*" } } diff --git a/node_modules/slash/readme.md b/node_modules/slash/readme.md index 42f74f90..5e2fedbc 100644 --- a/node_modules/slash/readme.md +++ b/node_modules/slash/readme.md @@ -1,36 +1,44 @@ -# slash +# slash [](https://travis-ci.org/sindresorhus/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. +[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. + +This was created since the `path` methods in Node outputs `\\` paths on Windows. -This was created since the `path` methods in Node.js outputs `\\` paths on Windows. ## Install -```sh -npm install slash +``` +$ npm install slash ``` + ## Usage ```js -import path from 'node:path'; -import slash from 'slash'; +const path = require('path'); +const slash = require('slash'); -const string = path.join('foo', 'bar'); +const str = path.join('foo', 'bar'); // Unix => foo/bar // Windows => foo\\bar -slash(string); +slash(str); // Unix => foo/bar // Windows => foo/bar ``` + ## API ### slash(path) Type: `string` -Accepts a Windows backslash path and returns a path with forward slashes. +Accepts a Windows backslash path and returns a slash path. + + +## License + +MIT © [Sindre Sorhus](https://sindresorhus.com) |
