From b596b5bb7dbaf0ddb024fa7183e505dcf96dc12b Mon Sep 17 00:00:00 2001 From: Vincent Flyson Date: Sat, 24 Aug 2019 14:22:34 -0400 Subject: [PATCH] Ignore icons if told to avoid images --- src/html.rs | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/html.rs b/src/html.rs index 57085fc..de31305 100644 --- a/src/html.rs +++ b/src/html.rs @@ -137,15 +137,20 @@ pub fn walk_and_embed_assets( NodeMatch::Icon => { for attr in attrs_mut.iter_mut() { if &attr.name.local == "href" { - let href_full_url = resolve_url(&url, &attr.value.to_string()); - let favicon_datauri = retrieve_asset( - &href_full_url.unwrap(), - true, - "", - opt_user_agent, - ); - attr.value.clear(); - attr.value.push_slice(favicon_datauri.unwrap().as_str()); + if opt_no_images { + attr.value.clear(); + attr.value.push_slice(TRANSPARENT_PIXEL); + } else { + let href_full_url = resolve_url(&url, &attr.value.to_string()); + let favicon_datauri = retrieve_asset( + &href_full_url.unwrap(), + true, + "", + opt_user_agent, + ); + attr.value.clear(); + attr.value.push_slice(favicon_datauri.unwrap().as_str()); + } } } }