fix: Split the haystack lines

Match each line separately

Signed-off-by: Awiteb <a@4rs.nl>
This commit is contained in:
Awiteb 2024-11-15 09:20:18 +00:00
parent ff7994686d
commit 880330576d
Signed by: awiteb
GPG key ID: 3F6B55640AA6682F

View file

@ -26,7 +26,11 @@ pub trait ExprChecker {
impl ExprChecker for Expr {
fn is_match<'a>(&'a self, user: &ForgejoUser) -> Option<Regex> {
let one_of = |hay, exprs: &'a Vec<Regex>| exprs.iter().find(|re| re.is_match(hay));
let one_of = |hay: &str, exprs: &'a Vec<Regex>| {
exprs
.iter()
.find(|re| hay.split('\n').any(|line| re.is_match(line.trim())))
};
[
one_of(&user.username, &self.usernames),
one_of(&user.full_name, &self.full_names),