diff --git a/packages/backend/src/routes/editor.ts b/packages/backend/src/routes/editor.ts index cb298e5..657773c 100644 --- a/packages/backend/src/routes/editor.ts +++ b/packages/backend/src/routes/editor.ts @@ -25,7 +25,8 @@ router.get("/tree/:repo", async (req, res) => { router.get("/file/:repo/*path", async (req, res) => { try { - const content = await readFile(req.params.repo, req.params.path); + const filePath = Array.isArray(req.params.path) ? req.params.path.join("/") : req.params.path; + const content = await readFile(req.params.repo, filePath); res.json({ content }); } catch (err: unknown) { const message = err instanceof Error ? err.message : "Unknown error"; @@ -35,7 +36,8 @@ router.get("/file/:repo/*path", async (req, res) => { router.put("/file/:repo/*path", async (req, res) => { try { - await writeFile(req.params.repo, req.params.path, req.body.content); + const filePath = Array.isArray(req.params.path) ? req.params.path.join("/") : req.params.path; + await writeFile(req.params.repo, filePath, req.body.content); res.json({ ok: true }); } catch (err: unknown) { const message = err instanceof Error ? err.message : "Unknown error"; @@ -45,7 +47,8 @@ router.put("/file/:repo/*path", async (req, res) => { router.delete("/file/:repo/*path", async (req, res) => { try { - await deleteFile(req.params.repo, req.params.path); + const filePath = Array.isArray(req.params.path) ? req.params.path.join("/") : req.params.path; + await deleteFile(req.params.repo, filePath); res.json({ ok: true }); } catch (err: unknown) { const message = err instanceof Error ? err.message : "Unknown error"; diff --git a/packages/backend/src/routes/repos.ts b/packages/backend/src/routes/repos.ts index 701fa52..e2aff93 100644 --- a/packages/backend/src/routes/repos.ts +++ b/packages/backend/src/routes/repos.ts @@ -143,7 +143,7 @@ router.get("/:repo/diff/*path", async (req, res) => { res.status(400).json({ error: `Unknown repo: ${repoName}` }); return; } - const filePath = req.params.path; + const filePath = Array.isArray(req.params.path) ? req.params.path.join("/") : req.params.path; const repoPath = getRepoPath(repoName); const diff = await getDiff(repoPath, filePath); res.json({ diff }); diff --git a/packages/backend/src/services/git.service.ts b/packages/backend/src/services/git.service.ts index c6acebf..849acad 100644 --- a/packages/backend/src/services/git.service.ts +++ b/packages/backend/src/services/git.service.ts @@ -1,4 +1,4 @@ -import simpleGit, { SimpleGit } from "simple-git"; +import { simpleGit, SimpleGit } from "simple-git"; import fs from "fs/promises"; import { REPOS, GIT_PROVIDER_URL, type RepoName } from "../config/repos.js"; import { getRepoPath, readConfig } from "./workspace.service.js";