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

Function fixDriveLetter

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

Source from the content-addressed store, hash-verified

132}
133
134export 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

Callers 3

resolveFunction · 0.90
rebaseRemoteToLocalFunction · 0.90
fixDriveLetterAndSlashesFunction · 0.85

Calls 3

isWindowsPathFunction · 0.85
substrMethod · 0.80
matchMethod · 0.45

Tested by 1

resolveFunction · 0.72