MCPcopy Create free account
hub / github.com/Snapchat/Valdi / fixDriveLetterAndSlashes

Function fixDriveLetterAndSlashes

valdi/vscode_debugger/src/common/pathUtils.ts:152–164  ·  view source on GitHub ↗
(aPath: string, uppercaseDriveLetter = false)

Source from the content-addressed store, hash-verified

150 * Ensure lower case drive letter and \ on Windows
151 */
152export function fixDriveLetterAndSlashes(aPath: string, uppercaseDriveLetter = false): string {
153 if (!aPath) return aPath;
154
155 aPath = fixDriveLetter(aPath, uppercaseDriveLetter);
156 if (aPath.match(/file:\/\/\/[A-Za-z]:/)) {
157 const prefixLen = 'file:///'.length;
158 aPath = aPath.substr(0, prefixLen + 1) + aPath.substr(prefixLen + 1).replace(/\//g, '\\');
159 } else if (isWindowsPath(aPath)) {
160 aPath = aPath.replace(/\//g, '\\');
161 }
162
163 return aPath;
164}
165
166/**
167 * Replace any backslashes with forward slashes

Callers 11

pathUtils.test.tsFile · 0.90
rebaseLocalToRemoteFunction · 0.90
tryGetCompiledFileMethod · 0.90
tryGetCompiledFileMethod · 0.90
fileUrlToAbsolutePathFunction · 0.90
getComputedSourceRootFunction · 0.90
computedSourceUrlMethod · 0.90

Calls 5

fixDriveLetterFunction · 0.85
isWindowsPathFunction · 0.85
substrMethod · 0.80
replaceMethod · 0.65
matchMethod · 0.45

Tested by

no test coverage detected