fix: parse log cause panic

This commit is contained in:
GyDi 2023-01-11 13:30:14 +08:00 committed by GitHub
parent 0cb802ed9a
commit e90158809a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -55,10 +55,13 @@ fn clash_client_info() -> Result<(String, HeaderMap)> {
/// 缩短clash的日志 /// 缩短clash的日志
pub fn parse_log(log: String) -> String { 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(); return (&log[33..]).to_owned();
} }
(&log[9..]).to_owned() if log.len() > 9 {
return (&log[9..]).to_owned();
}
return log;
} }
/// 缩短clash -t的错误输出 /// 缩短clash -t的错误输出