Fix: ensure Windows drive letters are lowercased and improve path parsing

This commit is contained in:
Elio Struyf
2025-02-12 12:27:24 +01:00
parent 482cbc3bf6
commit ee5af88851
2 changed files with 23 additions and 3 deletions

View File

@@ -636,15 +636,23 @@ export class Folders {
}
}
// For Windows, we need to make sure the drive letter is lowercased for consistency
if (isWindows()) {
folders = folders.map((folder) => parseWinPath(folder));
}
// Filter out the workspace folder
if (wsFolder) {
folders = folders.filter((folder) => folder !== wsFolder.fsPath);
folders = folders.filter((folder) => folder !== parseWinPath(wsFolder.fsPath));
}
const uniqueFolders = [...new Set(folders)];
const relativeFolderPaths = uniqueFolders.map((folder) =>
relative(parseWinPath(wsFolder.fsPath), folder)
);
Logger.verbose('Folders:getContentFolders:end');
return uniqueFolders.map((folder) => relative(wsFolder?.path || '', folder));
return relativeFolderPaths;
}
/**

View File

@@ -1,3 +1,15 @@
import { isWindows } from '../utils';
export const parseWinPath = (path: string | undefined): string => {
return path?.split(`\\`).join(`/`) || '';
path = path?.split(`\\`).join(`/`) || '';
if (isWindows()) {
// Check if path starts with a drive letter (e.g., "C:\")
if (/^[a-zA-Z]:\\/.test(path)) {
// Convert to lowercase drive letter
path = path.charAt(0).toLowerCase() + path.slice(1);
}
}
return path;
};