From 28710ab3ed213465627ca25d2c3003a3b4ffab51 Mon Sep 17 00:00:00 2001 From: Harsh Shandilya Date: Tue, 15 Feb 2022 02:40:27 +0530 Subject: [PATCH] fix: remove panicking flow --- src/config.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/config.rs b/src/config.rs index 8136ab1..6cca01a 100644 --- a/src/config.rs +++ b/src/config.rs @@ -63,8 +63,11 @@ impl Match for Matcher<'_> { Matcher::EndsWith { suffix } => string.ends_with(&suffix), Matcher::Contains { substring } => string.contains(&substring), Matcher::Regex { pattern } => { - let regex = Regex::from_str(pattern).expect("Failed to parse regex"); - regex.is_match(string) + return if let Ok(regex) = Regex::from_str(pattern) { + regex.is_match(string) + } else { + false + } } Matcher::Exactly { content } => string == content, }