From 64ba7fdb9af883d714e963df4459962be297bb3d Mon Sep 17 00:00:00 2001 From: Misha Skvortsov Date: Thu, 2 Apr 2026 12:27:12 +0300 Subject: [PATCH] refactor: enhance Atomic Chat API URL handling - Updated the `getAtomicChatApiBaseUrl` function to parse the base URL correctly and ensure the pathname is formatted without trailing version segments. - Cleared search and hash components from the URL to standardize the output. This change improves the robustness of the URL handling for the Atomic Chat provider. --- scripts/provider-discovery.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/scripts/provider-discovery.ts b/scripts/provider-discovery.ts index 9c463f2f..e65d2e8f 100644 --- a/scripts/provider-discovery.ts +++ b/scripts/provider-discovery.ts @@ -97,8 +97,16 @@ export async function listOllamaModels( // ── Atomic Chat discovery (Apple Silicon local LLMs at 127.0.0.1:1337) ────── export function getAtomicChatApiBaseUrl(baseUrl?: string): string { - const raw = baseUrl || process.env.ATOMIC_CHAT_BASE_URL || DEFAULT_ATOMIC_CHAT_BASE_URL - return trimTrailingSlash(raw) + const parsed = new URL( + baseUrl || process.env.ATOMIC_CHAT_BASE_URL || DEFAULT_ATOMIC_CHAT_BASE_URL, + ) + const pathname = trimTrailingSlash(parsed.pathname) + parsed.pathname = pathname.endsWith('/v1') + ? pathname.slice(0, -3) || '/' + : pathname || '/' + parsed.search = '' + parsed.hash = '' + return trimTrailingSlash(parsed.toString()) } export function getAtomicChatChatBaseUrl(baseUrl?: string): string {