Skip to content

Commit

Permalink
support $from as a $domain alias
Browse files Browse the repository at this point in the history
  • Loading branch information
antonok-edm committed Nov 13, 2023
1 parent 662d80c commit 1f966be
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/filters/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ fn parse_filter_options(raw_options: &str) -> Result<Vec<NetworkFilterOption>, N
);

result.push(match (option, negation) {
("domain", _) => {
("domain", _) | ("from", _) => {
let domains: Vec<(bool, String)> = value.split('|').map(|domain| {
if let Some(negated_domain) = domain.strip_prefix('~') {
(false, negated_domain.to_string())
Expand Down Expand Up @@ -2281,6 +2281,12 @@ mod parse_tests {
assert_eq!(filter.opt_domains, None);
assert_eq!(filter.opt_not_domains, None);
}
// `from` is an alias for `domain`
{
let filter = NetworkFilter::parse("||foo.com$from=bar.com", true, Default::default()).unwrap();
assert_eq!(filter.opt_domains, Some(vec![utils::fast_hash("bar.com")]));
assert_eq!(filter.opt_not_domains, None);
}
}

#[test]
Expand Down

0 comments on commit 1f966be

Please sign in to comment.