| 132 | } |
| 133 | |
| 134 | export function fixDriveLetter(aPath: string, uppercaseDriveLetter = false): string { |
| 135 | if (!aPath) return aPath; |
| 136 | |
| 137 | if (aPath.match(/file:\/\/\/[A-Za-z]:/)) { |
| 138 | const prefixLen = 'file:///'.length; |
| 139 | aPath = 'file:///' + aPath[prefixLen].toLowerCase() + aPath.substr(prefixLen + 1); |
| 140 | } else if (isWindowsPath(aPath)) { |
| 141 | // If the path starts with a drive letter, ensure lowercase. VS Code uses a lowercase drive letter |
| 142 | const driveLetter = uppercaseDriveLetter ? aPath[0].toUpperCase() : aPath[0].toLowerCase(); |
| 143 | aPath = driveLetter + aPath.substr(1); |
| 144 | } |
| 145 | |
| 146 | return aPath; |
| 147 | } |
| 148 | |
| 149 | /** |
| 150 | * Ensure lower case drive letter and \ on Windows |