Fix double slash in WebSocket URL by stripping trailing slash from base URL

This commit is contained in:
Graham McIntire 2026-01-16 20:08:13 -06:00
parent 451b530641
commit 02ea81cae3
No known key found for this signature in database

View file

@ -52,7 +52,9 @@ impl AgentClient {
/// let client = AgentClient::connect("wss://towerops.net", "token123").await?;
/// ```
pub async fn connect(url: &str, token: &str) -> Result<Self> {
let ws_url = format!("{}/socket/agent/websocket", url);
// Strip trailing slash from base URL to avoid double slashes
let base_url = url.trim_end_matches('/');
let ws_url = format!("{}/socket/agent/websocket", base_url);
log::info!("Connecting to WebSocket: {}", ws_url);
let (mut ws_stream, _) = connect_async(&ws_url)