Normalize paths by removing both leading and trailing slashes

This commit is contained in:
Torsten Dittmann
2025-05-16 14:14:08 +02:00
parent c50f56620c
commit 93bd9bf5ed
@@ -72,8 +72,10 @@ export function treeFromFilesystem(files: SvelteSet<string>): TreeItem[] {
const tree: TreeItem[] = [];
for (const path of Array.from(files)) {
const normalizedPath = path.endsWith('/') ? path.slice(0, -1) : path;
let normalizedPath = path.endsWith('/') ? path.slice(0, -1) : path;
if (normalizedPath.startsWith('/')) {
normalizedPath = normalizedPath.slice(1);
}
if (!normalizedPath) continue;
const parts = normalizedPath.split('/');