diff options
author | Erik Johnston <erik@matrix.org> | 2022-09-07 17:17:24 +0100 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2022-09-09 15:10:52 +0100 |
commit | cdd83480dcaaeeb34a3302725a4c03e229afc390 (patch) | |
tree | e4f04ddd25383712f15c3491c469401e1c72cf33 /rust/src/push/utils.rs | |
parent | Revert debug logging (diff) | |
download | synapse-cdd83480dcaaeeb34a3302725a4c03e229afc390.tar.xz |
Fix power levels and tests github/erikj/rust_push_evaluator erikj/rust_push_evaluator
Diffstat (limited to 'rust/src/push/utils.rs')
-rw-r--r-- | rust/src/push/utils.rs | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/rust/src/push/utils.rs b/rust/src/push/utils.rs index d070d8f0d2..dcf1a39bc5 100644 --- a/rust/src/push/utils.rs +++ b/rust/src/push/utils.rs @@ -52,7 +52,10 @@ pub(crate) fn glob_to_regex(glob: &str, match_type: GlobMatchType) -> Result<Reg let regex_str = match match_type { GlobMatchType::Whole => format!(r"\A{joined}\z"), - GlobMatchType::Word => format!(r"\b{joined}\b"), + + // `^|\W` and `\W|$` handle the case where `pattern` starts or ends with a non-word + // character. + GlobMatchType::Word => format!(r"(?:^|\W|\b){joined}(?:\b|\W|$)"), }; Ok(RegexBuilder::new(®ex_str) |