Skip to content
This repository was archived by the owner on Jan 5, 2023. It is now read-only.

Commit b28cb12

Browse files
Chan Chak ShingHainish
authored andcommitted
Fix wildcard rules handling issue
1 parent 9a1806b commit b28cb12

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

src/rulesets.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ impl RuleSets {
388388
for index in 0..(segmented.len() - 1) {
389389
let mut segmented_tmp = segmented.clone();
390390
segmented_tmp[index] = "*";
391-
let tmp_host = segmented_tmp.join(".");
391+
let tmp_host = &segmented_tmp[index..segmented.len()].join(".");
392392
self.try_add(&mut results, &tmp_host);
393393
}
394394

@@ -451,7 +451,10 @@ pub mod tests {
451451
let mut rs = RuleSets::new();
452452
add_mock_rulesets(&mut rs);
453453

454+
assert_eq!(rs.potentially_applicable(&String::from("foo.1fichier.com")).len(), 1);
455+
assert_eq!(rs.potentially_applicable(&String::from("bar.foo.1fichier.com")).len(), 1);
454456
assert_eq!(rs.potentially_applicable(&String::from("foo.storage.googleapis.com")).len(), 1);
457+
assert_eq!(rs.potentially_applicable(&String::from("bar.foo.storage.googleapis.com")).len(), 1);
455458
}
456459

457460
#[test]

0 commit comments

Comments
 (0)