diff --git a/src/stats.ts b/src/stats.ts index 78f9c22..fea030f 100644 --- a/src/stats.ts +++ b/src/stats.ts @@ -271,9 +271,9 @@ export function resolveServerUrls(options: unknown, providers: unknown, config: if (server !== undefined) { console.warn("[oc-ls-stats] ignoring invalid 'server' plugin option, falling back to provider detection") } - const detected = extractProviderUrlsFromList(providers) + const detected = [...new Set(extractProviderUrlsFromList(providers))] if (detected.length > 0) return detected - const legacy = extractProviderUrls(config) + const legacy = [...new Set(extractProviderUrls(config))] return legacy.length > 0 ? legacy : ["http://localhost:8080"] } diff --git a/test-backoff.ts b/test-backoff.ts index 1bf6236..787a860 100644 --- a/test-backoff.ts +++ b/test-backoff.ts @@ -215,3 +215,11 @@ test("selectSessionUrls first match wins for duplicate ids", () => { ] assert.deepEqual(selectSessionUrls(candidates, providers, "dup"), ["http://b:2"]) }) + +test("duplicate provider URLs are deduped", () => { + const providers = [ + { id: "llamacpp-a", name: "A", options: { baseURL: "http://same:7" } }, + { id: "llamacpp-b", name: "B", options: { baseURL: "http://same:7/v1" } }, + ] + assert.deepEqual(resolveServerUrls(undefined, providers, {}), ["http://same:7"]) +})