From 93bd9bf5ed604b01f6b694baf1aa2bcabc329f0d Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Fri, 16 May 2025 14:14:08 +0200 Subject: [PATCH] Normalize paths by removing both leading and trailing slashes --- src/lib/components/editor/(filesystem)/index.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/lib/components/editor/(filesystem)/index.ts b/src/lib/components/editor/(filesystem)/index.ts index 34b1fb347..a34e8db4f 100644 --- a/src/lib/components/editor/(filesystem)/index.ts +++ b/src/lib/components/editor/(filesystem)/index.ts @@ -72,8 +72,10 @@ export function treeFromFilesystem(files: SvelteSet): 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('/');