From e90158809a9b4e2d732faa136be824cd9fe22b17 Mon Sep 17 00:00:00 2001 From: GyDi Date: Wed, 11 Jan 2023 13:30:14 +0800 Subject: [PATCH] fix: parse log cause panic --- src-tauri/src/core/clash_api.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src-tauri/src/core/clash_api.rs b/src-tauri/src/core/clash_api.rs index eab08b4..4714371 100644 --- a/src-tauri/src/core/clash_api.rs +++ b/src-tauri/src/core/clash_api.rs @@ -55,10 +55,13 @@ fn clash_client_info() -> Result<(String, HeaderMap)> { /// 缩短clash的日志 pub fn parse_log(log: String) -> String { - if log.starts_with("time=") { + if log.starts_with("time=") && log.len() > 33 { return (&log[33..]).to_owned(); } - (&log[9..]).to_owned() + if log.len() > 9 { + return (&log[9..]).to_owned(); + } + return log; } /// 缩短clash -t的错误输出