From c65f6fa05f1fbc4703ca3d9af1f7581ff4ac7e84 Mon Sep 17 00:00:00 2001 From: purocean Date: Mon, 27 Jan 2025 21:25:00 +0800 Subject: [PATCH] fix: ensure paths start with a leading slash in withRepo function --- src/main/server/file.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/server/file.ts b/src/main/server/file.ts index fab8d3e3..0a292aca 100644 --- a/src/main/server/file.ts +++ b/src/main/server/file.ts @@ -82,6 +82,11 @@ function withRepo (repo = 'main', callback: (repoPath: string, ...targetPath: } return callback(repoPath, ...target.map(x => { + // fix path + if (!x.startsWith('/')) { + x = '/' + x + } + const targetPath = isRootRepo ? x.replace(/^\//, repoPath) // replace first / to repoPath for case of `\\127.0.0.1/test/a.md` : path.join(repoPath, x)