From 4cd0be194ed008120c7db66abdc83f068fd4d0b8 Mon Sep 17 00:00:00 2001 From: neonphog Date: Tue, 23 Apr 2024 10:47:07 -0600 Subject: [PATCH] address code review comments --- rust/sbd-client/src/raw_client.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/rust/sbd-client/src/raw_client.rs b/rust/sbd-client/src/raw_client.rs index 912dcd8..31e08a1 100644 --- a/rust/sbd-client/src/raw_client.rs +++ b/rust/sbd-client/src/raw_client.rs @@ -31,8 +31,10 @@ impl WsRawConnect { danger_disable_certificate_check, } = self; - let scheme_ws = full_url.starts_with("ws://"); - let scheme_wss = full_url.starts_with("wss://"); + let request = tokio_tungstenite::tungstenite::client::IntoClientRequest::into_client_request(full_url).map_err(Error::other)?; + + let scheme_ws = request.uri().scheme_str() == Some("ws"); + let scheme_wss = request.uri().scheme_str() == Some("wss"); if !scheme_ws && !scheme_wss { return Err(Error::other("scheme must be ws:// or wss://")); @@ -42,8 +44,6 @@ impl WsRawConnect { return Err(Error::other("plain text scheme not allowed")); } - let request = tokio_tungstenite::tungstenite::client::IntoClientRequest::into_client_request(full_url).map_err(Error::other)?; - let host = match request.uri().host() { Some(host) => host.to_string(), None => return Err(Error::other("invalid url")),