Skip to content

Commit

Permalink
Skip assets with nohash attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
prasmussen committed Aug 26, 2022
1 parent 2111d62 commit 2e2ad50
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/asset_hasher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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<String> {
extract_attribute_value(s, "href")
}
Expand Down

0 comments on commit 2e2ad50

Please sign in to comment.