|
| 1 | +/* |
| 2 | +Inlined from |
| 3 | +<https://github.com/sindresorhus/slash/blob/98b618f5a3bfcb5dd374b204868818845b87bb2f/index.js>, |
| 4 | +since we need a CJS version. |
| 5 | +
|
| 6 | +Copyright 2023 Sindre Sorhus |
| 7 | +
|
| 8 | +Permission is hereby granted, free of charge, to any person obtaining a copy of |
| 9 | +this software and associated documentation files (the “Software”), to deal in |
| 10 | +the Software without restriction, including without limitation the rights to |
| 11 | +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of |
| 12 | +the Software, and to permit persons to whom the Software is furnished to do so, |
| 13 | +subject to the following conditions: |
| 14 | +
|
| 15 | +The above copyright notice and this permission notice shall be included in all |
| 16 | +copies or substantial portions of the Software. |
| 17 | +
|
| 18 | +THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 19 | +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS |
| 20 | +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR |
| 21 | +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER |
| 22 | +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
| 23 | +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 24 | +*/ |
| 25 | + |
| 26 | +function slash(path) { |
| 27 | + const isExtendedLengthPath = path.startsWith('\\\\?\\'); |
| 28 | + |
| 29 | + if (isExtendedLengthPath) { |
| 30 | + return path; |
| 31 | + } |
| 32 | + |
| 33 | + return path.replace(/\\/g, '/'); |
| 34 | +} |
| 35 | + |
| 36 | +module.exports = slash; |
0 commit comments