From 2e2ad50bc690193cc11955f70f634c7beac1a734 Mon Sep 17 00:00:00 2001 From: Petter Rasmussen Date: Fri, 26 Aug 2022 21:30:27 +0300 Subject: [PATCH] Skip assets with nohash attribute --- src/asset_hasher.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/asset_hasher.rs b/src/asset_hasher.rs index d0614a1..7fcc643 100644 --- a/src/asset_hasher.rs +++ b/src/asset_hasher.rs @@ -97,12 +97,12 @@ impl AssetHasher { let link_assets = content .lines() - .filter(|line| is_link_asset(line)) + .filter(|line| is_link_asset(line) && !has_nohash(line)) .filter_map(extract_link_href); let script_assets = content .lines() - .filter(|line| is_script_asset(line)) + .filter(|line| is_script_asset(line) && !has_nohash(line)) .filter_map(extract_script_src); let assets = link_assets @@ -178,6 +178,10 @@ fn is_script_asset(s: &str) -> bool { s.contains("script") && s.contains("src") } +fn has_nohash(s: &str) -> bool { + s.contains("nohash") +} + fn extract_link_href(s: &str) -> Option { extract_attribute_value(s, "href") }