From 674acb4d02f3b710447b8e2a5e05631417ef2a34 Mon Sep 17 00:00:00 2001 From: Shodipo Ayomide Date: Tue, 26 Aug 2025 21:25:49 +0100 Subject: [PATCH] fix: url path trailing slash for custom-providers (#4345) Signed-off-by: developerayo --- crates/goose/src/providers/api_client.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/crates/goose/src/providers/api_client.rs b/crates/goose/src/providers/api_client.rs index 3e6ced8c..0ce3b05b 100644 --- a/crates/goose/src/providers/api_client.rs +++ b/crates/goose/src/providers/api_client.rs @@ -297,8 +297,14 @@ impl ApiClient { fn build_url(&self, path: &str) -> Result { use url::Url; - let base_url = + let mut base_url = Url::parse(&self.host).map_err(|e| anyhow::anyhow!("Invalid base URL: {}", e))?; + + let base_path = base_url.path(); + if !base_path.is_empty() && base_path != "/" && !base_path.ends_with('/') { + base_url.set_path(&format!("{}/", base_path)); + } + base_url .join(path) .map_err(|e| anyhow::anyhow!("Failed to construct URL: {}", e))