From 4027afcf6ec0a1dad3c260e3ece565cd2efe6b43 Mon Sep 17 00:00:00 2001 From: Daniel Micay Date: Fri, 26 Nov 2021 19:41:37 -0500 Subject: add integrity metadata to preload header --- process-static | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'process-static') diff --git a/process-static b/process-static index ac809e0d..307dc9ed 100755 --- a/process-static +++ b/process-static @@ -27,17 +27,17 @@ find static-tmp -name '*.js' -exec terser --ecma 2021 --module -cmo {} {} \; replace="" for file in static-tmp/**/*.css static-tmp/js/*.js static-tmp/mask-icon.svg; do hash=$(sha256sum "$file" | head -c 8) + sri_hash=sha256-$(openssl dgst -sha256 -binary "$file" | openssl base64 -A) dest="$(dirname $file)/$hash.$(basename $file)" if [[ $file == *.css ]]; then - sri_hash=sha256-$(openssl dgst -sha256 -binary "$file" | openssl base64 -A) replace+=";s@{{css|/${file#*/}}}@@g" elif [[ $file == *.js ]]; then - sri_hash=sha256-$(openssl dgst -sha256 -binary "$file" | openssl base64 -A) replace+=";s@{{js|/${file#*/}}}@@g" fi mv "$file" "$dest" + replace+=";s@{{integrity|/${file#*/}}}@${sri_hash}@g" replace+=";s@{{path|/${file#*/}}}@/${dest#*/}@g" done -- cgit v1.3.1