From 56a9496f986f937ef5d1bb8781403a628e84e10b Mon Sep 17 00:00:00 2001 From: Mike Swanson Date: Tue, 30 Dec 2025 06:08:29 -0700 Subject: [PATCH] Fix protocol URL parsing - action is host, session is path --- agent/src/install.rs | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/agent/src/install.rs b/agent/src/install.rs index 675aa4d..c25c61f 100644 --- a/agent/src/install.rs +++ b/agent/src/install.rs @@ -352,6 +352,8 @@ pub fn parse_protocol_url(url: &str) -> Result<(String, String, Option)> // guruconnect://view/SESSION_ID // guruconnect://view/SESSION_ID?token=API_KEY // guruconnect://connect/SESSION_ID?server=wss://...&token=API_KEY + // + // Note: In URL parsing, "view" becomes the host, SESSION_ID is the path let url = url::Url::parse(url) .map_err(|e| anyhow!("Invalid URL: {}", e))?; @@ -360,17 +362,22 @@ pub fn parse_protocol_url(url: &str) -> Result<(String, String, Option)> return Err(anyhow!("Invalid scheme: expected guruconnect://")); } + // The "action" (view/connect) is parsed as the host + let action = url.host_str() + .ok_or_else(|| anyhow!("Missing action in URL"))?; + + // The session ID is the first path segment let path = url.path().trim_start_matches('/'); - let parts: Vec<&str> = path.split('/').collect(); + let session_id = if path.is_empty() { + return Err(anyhow!("Missing session ID")); + } else { + path.split('/').next().unwrap_or("").to_string() + }; - if parts.is_empty() { - return Err(anyhow!("Missing action in URL")); + if session_id.is_empty() { + return Err(anyhow!("Missing session ID")); } - let action = parts[0]; - let session_id = parts.get(1).map(|s| s.to_string()) - .ok_or_else(|| anyhow!("Missing session ID"))?; - // Extract query parameters let mut server = None; let mut token = None;