diff --git a/src/engine.rs b/src/engine.rs index 835a0977..204f4552 100644 --- a/src/engine.rs +++ b/src/engine.rs @@ -154,22 +154,6 @@ impl Engine { self.blocker.get_csp_directives(request) } - /// Check if a given filter has been previously added to this `Engine`. - /// - /// Note that only network filters are currently supported by this method. - pub fn filter_exists(&self, filter: &str) -> bool { - use crate::filters::network::NetworkFilter; - let filter_parsed = NetworkFilter::parse(filter, false, Default::default()); - match filter_parsed.map(|f| self.blocker.filter_exists(&f)) { - Ok(exists) => exists, - Err(_e) => { - #[cfg(test)] - eprintln!("Encountered unparseable filter when checking for filter existence: {:?}", _e); - false - } - } - } - /// Sets this engine's tags to be _only_ the ones provided in `tags`. /// /// Tags can be used to cheaply enable or disable network rules with a corresponding `$tag` diff --git a/tests/legacy_harness.rs b/tests/legacy_harness.rs index 51de9c4a..0d20645e 100644 --- a/tests/legacy_harness.rs +++ b/tests/legacy_harness.rs @@ -686,15 +686,13 @@ mod legacy_misc_tests { let mut engine2 = Engine::new(false); engine2.deserialize(&serialized).unwrap(); - assert!(engine.filter_exists("||googlesyndication.com$third-party")); - assert!(engine2.filter_exists("||googlesyndication.com$third-party")); - assert!(!engine.filter_exists("||googleayndication.com$third-party")); - assert!(!engine2.filter_exists("||googleayndication.com$third-party")); - - assert!(engine.filter_exists("@@||googlesyndication.ca")); - assert!(engine2.filter_exists("@@||googlesyndication.ca")); - assert!(!engine.filter_exists("googlesyndication.ca")); - assert!(!engine2.filter_exists("googlesyndication.ca")); + assert!(engine.check_network_request(&Request::new("https://googlesyndication.com/script.js", "https://example.com", "script").unwrap()).matched); + assert!(engine2.check_network_request(&Request::new("https://googlesyndication.com/script.js", "https://example.com", "script").unwrap()).matched); + assert!(!engine.check_network_request(&Request::new("https://googleayndication.com/script.js", "https://example.com", "script").unwrap()).matched); + assert!(!engine2.check_network_request(&Request::new("https://googleayndication.com/script.js", "https://example.com", "script").unwrap()).matched); + + assert!(!engine.check_network_request(&Request::new("https://googlesyndication.ca/script.js", "https://example.com", "script").unwrap()).matched); + assert!(!engine2.check_network_request(&Request::new("https://googlesyndication.ca/script.js", "https://example.com", "script").unwrap()).matched); } #[test]