pub fn page_inline_hashes(html: &str) -> PageCspHashesExpand description
Computes the CSP source hashes for every inline block on a page.
Unlike the extraction pass (CspPlugin::transform_html), this
scan does not skip JSON-LD or livereload-marked scripts: it
hashes whatever is still inline in the HTML it is given, because
its consumers (the edge_headers postprocess plugin) run on the
final page bytes and need the policy to match what actually ships.
CSP directive source hashes are always SHA-256 for the broadest UA
compatibility; the [security] sri_algorithm knob governs only
SRI integrity= attributes (see the compute_sri doc comment).
ยงExamples
use ssg::csp::page_inline_hashes;
let html = r#"<script type="application/ld+json">{"@type":"Thing"}</script>"#;
let hashes = page_inline_hashes(html);
assert_eq!(hashes.scripts.len(), 1);
assert!(hashes.scripts[0].starts_with("sha256-"));
assert!(hashes.styles.is_empty());