From 7e3a85e9da50fbb62022459e35681ad3d7ffbdb2 Mon Sep 17 00:00:00 2001 From: GyDi Date: Wed, 1 Nov 2023 23:22:30 +0800 Subject: [PATCH] fix: latency url empty --- src-tauri/src/core/clash_api.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src-tauri/src/core/clash_api.rs b/src-tauri/src/core/clash_api.rs index 5dafcf6..0636b41 100644 --- a/src-tauri/src/core/clash_api.rs +++ b/src-tauri/src/core/clash_api.rs @@ -47,7 +47,11 @@ pub struct DelayRes { pub async fn get_proxy_delay(name: String, test_url: Option) -> Result { let (url, headers) = clash_client_info()?; let url = format!("{url}/proxies/{name}/delay"); - let test_url = test_url.unwrap_or("http://www.gstatic.com/generate_204".into()); + + let default_url = "http://www.gstatic.com/generate_204"; + let test_url = test_url + .map(|s| if s.is_empty() { default_url.into() } else { s }) + .unwrap_or(default_url.into()); let client = reqwest::ClientBuilder::new().no_proxy().build()?; let builder = client