summary refs log tree commit diff
path: root/rust/src/push/utils.rs
diff options
context:
space:
mode:
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)