diff --git a/src/opts.rs b/src/opts.rs index 8ef0d2c..5f57a07 100644 --- a/src/opts.rs +++ b/src/opts.rs @@ -53,7 +53,7 @@ impl Options { .args_from_usage("-c, --no-css 'Removes CSS'") .args_from_usage("-C, --charset=[UTF-8] 'Enforces custom encoding'") .args_from_usage( - "-D, --domains=[bad.org,ads.site,0.0.0.0,127.0.0.0:8080] 'Whitelist of domains'", + "-D, --domains=[bad.org,ads.site,127.0.0.0:8080] 'Whitelist of domains'", ) .args_from_usage("-e, --ignore-errors 'Ignore network errors'") .args_from_usage("-E, --exclude-domains 'Treat list of specified domains as blacklist'") diff --git a/src/utils.rs b/src/utils.rs index 6ea15b7..461a4a7 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -266,12 +266,23 @@ pub fn retrieve_asset( "".to_string(), )) } else { - if let Some(domains) = &options.domains { - if domains - .iter() - .any(|d| domain_is_within_domain(url.host_str().unwrap(), &d.trim())) - { - return Err(client.get("").send().unwrap_err()); + if options.exclude_domains { + if let Some(domains) = &options.domains { + if domains + .iter() + .any(|d| domain_is_within_domain(url.host_str().unwrap(), &d.trim())) + { + return Err(client.get("").send().unwrap_err()); + } + } + } else { + if let Some(domains) = &options.domains { + if domains + .iter() + .any(|d| !domain_is_within_domain(url.host_str().unwrap(), &d.trim())) + { + return Err(client.get("").send().unwrap_err()); + } } }