mirror of
https://git.sync.wtf/troed/oc-ls-stats.git
synced 2026-10-10 12:38:22 +03:00
feat: narrow polled servers to the current session's provider
This commit is contained in:
1 parent
cad446da2b
commit
ce2f7d5baf
2 files changed
+82
-1
No files matched your search
@@ -276,3 +276,28 @@ export function resolveServerUrls(options: unknown, providers: unknown, config:
|
||||
const legacy = extractProviderUrls(config)
|
||||
return legacy.length > 0 ? legacy : ["http://localhost:8080"]
|
||||
}
|
||||
|
||||
export function selectSessionUrls(
|
||||
candidates: string[],
|
||||
providers: unknown,
|
||||
providerID: string | undefined,
|
||||
): string[] {
|
||||
if (!providerID || providerID.trim() === "" || candidates.length === 0) return candidates
|
||||
if (!Array.isArray(providers)) return candidates
|
||||
for (const entry of providers) {
|
||||
if (!entry || typeof entry !== "object") continue
|
||||
const provider = entry as Record<string, unknown>
|
||||
if (provider.id !== providerID) continue
|
||||
const opts = provider.options
|
||||
if (opts && typeof opts === "object") {
|
||||
const baseURL =
|
||||
(opts as Record<string, unknown>).baseURL || (opts as Record<string, unknown>).base_url
|
||||
if (typeof baseURL === "string") {
|
||||
const normalized = stripBaseUrlPath(baseURL)
|
||||
if (candidates.includes(normalized)) return [normalized]
|
||||
}
|
||||
}
|
||||
break
|
||||
}
|
||||
return candidates
|
||||
}
|
||||
Reference in new issue
Block a user