From 0e7e209294689a3d378c973736d902be76ecd6fb Mon Sep 17 00:00:00 2001 From: Joel Wurtz Date: Wed, 13 Nov 2024 16:28:48 +0100 Subject: [PATCH] fix(browsers): fix panic when version compare fail --- src/parsers/client/browsers.rs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/parsers/client/browsers.rs b/src/parsers/client/browsers.rs index fa00187..acea0cb 100644 --- a/src/parsers/client/browsers.rs +++ b/src/parsers/client/browsers.rs @@ -401,15 +401,14 @@ impl BrowserClientList { .unwrap_or(Ordering::Equal) }); - engine_versions - .into_iter() - .for_each(|(engine_version, eng)| { - if let Cmp::Eq | Cmp::Gt = - version_compare::compare(version, engine_version).expect("valid version") - { - engine = Some(eng.clone()) + for (engine_version, eng) in &engine_versions { + match version_compare::compare(version, engine_version) { + Ok(Cmp::Eq) | Ok(Cmp::Gt) => { + engine = Some(eng.to_string()); } - }); + _ => {} + } + } engine = engine.or_else(|| entry_engine.default.clone());