From 1555d8c28289bf0487061396869af8529493ef2f Mon Sep 17 00:00:00 2001 From: Rudy Celekli Date: Sun, 25 Oct 2026 12:03:38 -0400 Subject: [PATCH] fix: read OLLAMA_HOST when its scheme is not lowercase HTTP://gpu.lan:11434 is the same server as http://gpu.lan:11434. The scheme was matched case-sensitively, so the value was rejected and graphicle config set model ollama saved http://127.0.0.1:11434 instead. Signed-off-by: Rudy Celekli --- crates/graphicle/src/terminal.rs | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/crates/graphicle/src/terminal.rs b/crates/graphicle/src/terminal.rs index 872ec206..8bd8bbbc 100644 --- a/crates/graphicle/src/terminal.rs +++ b/crates/graphicle/src/terminal.rs @@ -2427,9 +2427,11 @@ pub fn ollama_url(value: &str) -> Option { } let (scheme, rest, default_port) = match value.split_once("://") { None => ("http", value, 11434), - Some(("http", rest)) => ("http", rest, 80), - Some(("https", rest)) => ("https", rest, 443), - Some(_) => return None, + Some((raw, rest)) => match raw.to_ascii_lowercase().as_str() { + "http" => ("http", rest, 80), + "https" => ("https", rest, 443), + _ => return None, + }, }; let hostport = rest.split('/').next().unwrap_or_default(); let (host, port) = if let Some(bracketed) = hostport.strip_prefix('[') { @@ -5958,6 +5960,18 @@ args = ["-y", "thing"] for value in ["", " ", "ftp://host", "host:port", "[::1"] { assert_eq!(ollama_url(value), None, "{value}"); } + // A scheme is case-insensitive. Rejecting HTTP:// makes config set + // ignore OLLAMA_HOST and save http://127.0.0.1:11434. + for (value, url) in [ + ("HTTP://gpu.lan:11434", "http://gpu.lan:11434"), + ( + "Https://ollama.example.com", + "https://ollama.example.com:443", + ), + ("HTTP://[::1]:11434", "http://[::1]:11434"), + ] { + assert_eq!(ollama_url(value).as_deref(), Some(url), "{value}"); + } let profile = model_profile_at("ollama", None, None, None, "http://[::1]:11500").unwrap(); assert_eq!(profile["base_url"], "http://[::1]:11500"); let explicit = model_profile_at(