fix: remove panicking flow

This commit is contained in:
Harsh Shandilya 2022-02-15 02:40:27 +05:30
parent 127c81292d
commit 28710ab3ed
No known key found for this signature in database
GPG Key ID: 366D7BBAD1031E80
1 changed files with 5 additions and 2 deletions

View File

@ -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,
}