Skip to content

Instantly share code, notes, and snippets.

@avioli
Last active February 14, 2017 01:20
Show Gist options
  • Save avioli/f80cccd25f11921c65267c1b047a5a34 to your computer and use it in GitHub Desktop.
Save avioli/f80cccd25f11921c65267c1b047a5a34 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
test -n "$2" && EXT=$2 || EXT=${1##*.}
INTEGRITY=$(curl -sL "$1" | openssl dgst -sha384 -binary | openssl enc -base64 -A)
if [ "$EXT" = "css" ]; then
echo '<link rel="stylesheet" href="'$1'" integrity="sha384-'$INTEGRITY'" crossorigin="anonymous">'
else
echo '<script src="'$1'" integrity="sha384-'$INTEGRITY'" crossorigin="anonymous"></script>'
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment