From 880330576dffa09909beee8c1ec3570f40915adc Mon Sep 17 00:00:00 2001 From: Awiteb Date: Fri, 15 Nov 2024 09:20:18 +0000 Subject: [PATCH] fix: Split the haystack lines Match each line separately Signed-off-by: Awiteb --- src/traits.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/traits.rs b/src/traits.rs index 9c730de..29d610c 100644 --- a/src/traits.rs +++ b/src/traits.rs @@ -26,7 +26,11 @@ pub trait ExprChecker { impl ExprChecker for Expr { fn is_match<'a>(&'a self, user: &ForgejoUser) -> Option { - let one_of = |hay, exprs: &'a Vec| exprs.iter().find(|re| re.is_match(hay)); + let one_of = |hay: &str, exprs: &'a Vec| { + 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),