278
279
export function sanitizeFilePath(candidate: string, cwd: string): string {
281
>
// Special case: allow to open a drive letter without trailing backslash
282
>
if (isWindows && candidate.endsWith(':')) {
283
candidate += sep;
284
}
286
>
// Ensure absolute
287
>
if (!isAbsolute(candidate)) {
288
>
candidate = join(cwd, candidate);
289
>
}
290
>
291
>
// Ensure normalized
292
>
candidate = normalize(candidate);
293
>
294
>
// Ensure no trailing slash/backslash
295
>
return removeTrailingPathSeparator(candidate);
296
>
}
297
298
export function removeTrailingPathSeparator(candidate: string): string {
300
candidate = rtrim(candidate, sep);
301