Skip to content

Commit 5bb4b11

Browse files
committed
fix: restrict matching for double star pattern
1 parent 952eed4 commit 5bb4b11

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

relay-cabi/src/codeowners.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,14 @@ fn translate_codeowners_pattern(pattern: &str) -> Option<Regex> {
6565
let trailing_slash = pattern_vec.get(i + 2) == Some(&'/');
6666

6767
if (left_anchored || leading_slash) && (right_anchored || trailing_slash) {
68-
regex += ".*";
69-
num_to_skip = Some(2);
70-
// Allows the trailing slash after ** to be optional
7168
if trailing_slash {
72-
regex += "/?";
69+
// **/ matches zero or more complete path segments
70+
regex += "(?:.*/)?";
7371
num_to_skip = Some(3);
72+
} else {
73+
// ** at end matches anything
74+
regex += ".*";
75+
num_to_skip = Some(2);
7476
}
7577
continue;
7678
}

0 commit comments

Comments
 (0)