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