fix: Matching users multiline description correctly
Reported-by: Awiteb <a@4rs.nl> Fixes: #2 Signed-off-by: Awiteb <a@4rs.nl>
This commit is contained in:
parent
7a0f3fab27
commit
3d6b49c01a
1 changed files with 10 additions and 4 deletions
|
@ -28,10 +28,16 @@ pub trait ExprChecker {
|
|||
impl ExprChecker for Expr {
|
||||
fn is_match<'a>(&'a self, user: &ForgejoUser) -> Option<RegexReason> {
|
||||
let one_of = |hay: &str, exprs: &'a Vec<RegexReason>| {
|
||||
exprs.iter().find(|re| {
|
||||
hay.split('\n')
|
||||
.any(|line| re.re_vec.iter().all(|re| re.is_match(line.trim())))
|
||||
})
|
||||
// Join the user bio into a single line
|
||||
// ref: https://git.4rs.nl/awiteb/forgejo-guardian/issues/2
|
||||
let hay = if hay.contains('\n') {
|
||||
hay.split('\n').collect::<Vec<_>>().join(" ")
|
||||
} else {
|
||||
hay.to_string()
|
||||
};
|
||||
exprs
|
||||
.iter()
|
||||
.find(|re_re| re_re.re_vec.iter().all(|re| re.is_match(&hay)))
|
||||
};
|
||||
[
|
||||
one_of(&user.username, &self.usernames),
|
||||
|
|
Loading…
Reference in a new issue