Skip to content

Commit e522eb3

Browse files
committed
fix: Normalize Qdrant URL pathname to remove multiple trailing slashes
The previous commit may not work if there are multiple trailing slashes
1 parent 32ffeb4 commit e522eb3

File tree

2 files changed

+24
-9
lines changed

2 files changed

+24
-9
lines changed

src/services/code-index/vector-store/__tests__/qdrant-client.spec.ts

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,25 @@ describe("QdrantVectorStore", () => {
420420
expect((vectorStoreWithTrailingSlash as any).qdrantUrl).toBe("http://localhost:6333/api/")
421421
})
422422

423+
it("should normalize URL pathname by removing multiple trailing slashes for prefix", () => {
424+
const vectorStoreWithMultipleTrailingSlashes = new QdrantVectorStore(
425+
mockWorkspacePath,
426+
"http://localhost:6333/api///",
427+
mockVectorSize,
428+
)
429+
expect(QdrantClient).toHaveBeenLastCalledWith({
430+
host: "localhost",
431+
https: false,
432+
port: 6333,
433+
prefix: "/api", // All trailing slashes should be removed
434+
apiKey: undefined,
435+
headers: {
436+
"User-Agent": "Roo-Code",
437+
},
438+
})
439+
expect((vectorStoreWithMultipleTrailingSlashes as any).qdrantUrl).toBe("http://localhost:6333/api///")
440+
})
441+
423442
it("should handle multiple path segments correctly for prefix", () => {
424443
const vectorStoreWithMultiSegment = new QdrantVectorStore(
425444
mockWorkspacePath,
@@ -438,14 +457,10 @@ describe("QdrantVectorStore", () => {
438457
})
439458
expect((vectorStoreWithMultiSegment as any).qdrantUrl).toBe("http://localhost:6333/api/v1/qdrant")
440459
})
441-
442-
it("should handle complex URL with multiple segments, trailing slash, query params, and fragment", () => {
443-
const complexUrl = "https://example.com/ollama/api/v1/?key=value#pos"
444-
const vectorStoreComplex = new QdrantVectorStore(
445-
mockWorkspacePath,
446-
complexUrl,
447-
mockVectorSize,
448-
)
460+
461+
it("should handle complex URL with multiple segments, multiple trailing slashes, query params, and fragment", () => {
462+
const complexUrl = "https://example.com/ollama/api/v1///?key=value#pos"
463+
const vectorStoreComplex = new QdrantVectorStore(mockWorkspacePath, complexUrl, mockVectorSize)
449464
expect(QdrantClient).toHaveBeenLastCalledWith({
450465
host: "example.com",
451466
https: true,

src/services/code-index/vector-store/qdrant-client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export class QdrantVectorStore implements IVectorStore {
5757
host: urlObj.hostname,
5858
https: useHttps,
5959
port: port,
60-
prefix: urlObj.pathname === "/" ? undefined : urlObj.pathname.replace(/\/$/, ""),
60+
prefix: urlObj.pathname === "/" ? undefined : urlObj.pathname.replace(/\/+$/, ""),
6161
apiKey,
6262
headers: {
6363
"User-Agent": "Roo-Code",

0 commit comments

Comments
 (0)