mirror of
https://github.com/estruyf/vscode-front-matter.git
synced 2026-03-28 17:42:40 +01:00
Fix: ensure Windows drive letters are lowercased and improve path parsing
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user