* Convert a Windows absolute path to a Unix-style path. * Strips the drive letter (e.g., "C:") and converts backslashes to forward slashes. * * @example * windowsPathToUnix("C:\\Users\\siha\\file.txt") // returns "/Users/siha/file.txt" * windowsPathToUnix("D:\\projects\\myapp") // returns "/pro
(path)
| 41 | * windowsPathToUnix("D:\\projects\\myapp") // returns "/projects/myapp" |
| 42 | */ |
| 43 | function windowsPathToUnix(path) { |
| 44 | if (process.platform === "win32") { |
| 45 | // Remove drive letter (e.g., "C:" or "D:") |
| 46 | let unixPath = path.replace(/^[A-Za-z]:/, ""); |
| 47 | |
| 48 | // Replace all backslashes with forward slashes |
| 49 | unixPath = unixPath.replace(/\\/g, "/"); |
| 50 | |
| 51 | return unixPath; |
| 52 | } |
| 53 | return path; |
| 54 | } |
| 55 | |
| 56 | /** |
| 57 | * Escape backslashes in a Windows path for use in Python strings. |
no outgoing calls
no test coverage detected
searching dependent graphs…