Skip to content

Commit

Permalink
fix: ensure paths start with a leading slash in withRepo function
Browse files Browse the repository at this point in the history
  • Loading branch information
purocean committed Jan 27, 2025
1 parent 22d1b9e commit c65f6fa
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/main/server/file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ function withRepo<T> (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)
Expand Down

0 comments on commit c65f6fa

Please sign in to comment.