feat: add support for returning posix path separator on windows (#2056)

Co-authored-by: GitHub Action <action@github.com>
This commit is contained in:
Tonye Jack
2024-04-18 15:03:38 -06:00
committed by GitHub
parent 9f8300f8b4
commit 0874344d6e
13 changed files with 11446 additions and 26 deletions

View File

@@ -32,11 +32,13 @@ export const normalizeSeparators = (p: string): string => {
// Remove redundant slashes
const isUnc = /^\\\\+[^\\]/.test(p) // e.g. \\hello
return (isUnc ? '\\' : '') + p.replace(/\\\\+/g, '\\') // preserve leading \\ for UNC
p = (isUnc ? '\\' : '') + p.replace(/\\\\+/g, '\\') // preserve leading \\ for UNC
} else {
// Remove redundant slashes on Linux/macOS
p = p.replace(/\/\/+/g, '/')
}
// Remove redundant slashes
return p.replace(/\/\/+/g, '/')
return p
}
/**