summary refs log tree commit diff
path: root/rust/src/push/utils.rs
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2022-09-07 17:17:24 +0100
committerErik Johnston <erik@matrix.org>2022-09-09 15:10:52 +0100
commitcdd83480dcaaeeb34a3302725a4c03e229afc390 (patch)
treee4f04ddd25383712f15c3491c469401e1c72cf33 /rust/src/push/utils.rs
parentRevert debug logging (diff)
downloadsynapse-cdd83480dcaaeeb34a3302725a4c03e229afc390.tar.xz
Diffstat (limited to 'rust/src/push/utils.rs')
-rw-r--r--rust/src/push/utils.rs5
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(&regex_str)