Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/utils/normalize-path.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export function normalizePath(path: string): string {
if (!path || path === "/") return ""
let normalized = path.replace(/\\+/g, "/").replace(/\/\/+/, "/")
let normalized = path.replace(/\\+/g, "/").replace(/\/\/+/g, "/")
if (normalized.startsWith("/")) {
normalized = normalized.slice(1)
}
Expand Down
5 changes: 2 additions & 3 deletions tests/fixtures/get-test-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,15 @@ interface TestFixture {
}

export const getTestServer = async (): Promise<TestFixture> => {
const port = 3001 + Math.floor(Math.random() * 999)
const testInstanceId = Math.random().toString(36).substring(2, 15)
const testDbName = `testdb${testInstanceId}`

const server = await startServer({
port,
port: 0,
testDbName,
})

const url = `http://127.0.0.1:${port}`
const url = `http://127.0.0.1:${server.port}`
const axios = defaultAxios.create({
baseURL: url,
})
Expand Down
16 changes: 16 additions & 0 deletions tests/routes/files.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,22 @@ test("file download operations2", async () => {
})
})

test("download query paths normalize every repeated slash run", async () => {
const { axios } = await getTestServer()

await axios.post("/files/upsert", {
file_path: "/normalized/path/file.txt",
text_content: "Normalized repeated slashes",
})

const downloadRes = await axios.get("/files/download", {
params: { file_path: "/normalized//path///file.txt" },
})

expect(downloadRes.status).toBe(200)
expect(downloadRes.data).toBe("Normalized repeated slashes")
})

test("file delete operations", async () => {
const { axios } = await getTestServer()

Expand Down
Loading