englehardt / abp-blocklist-parser

A parser for Adblock Plus formatted blocklists.
Other
2 stars 2 forks source link

Refactor "option" parameter of `should_block` to "context" #4

Open englehardt opened 5 years ago

englehardt commented 5 years ago

The notion of providing "options" when passing in a URL is confusing. Unlike rules, URLs don't have a notion of options, but rather context around the request that would normally be matched against the options of a rule. It's currently entirely unclear how to format an "options" dictionary.

Ideally, we'll have a well defined interface with optional arguments:

We can then map these to options. i.e., if the request URL and top-level URL don't have the same eTLD+1, we consider the request third-party and match it against third-party-only rules.

englehardt commented 5 years ago

Options are checked here:

https://github.com/englehardt/abp-blocklist-parser/blob/40f6bb5b91ea403b7b9852a16d6c57d5ec26cf7f/abp_blocklist_parser/RegexParser.py#L104-L117

https://github.com/englehardt/abp-blocklist-parser/blob/40f6bb5b91ea403b7b9852a16d6c57d5ec26cf7f/abp_blocklist_parser/RegexParser.py#L240-L248