From 4c21f09d6b4f6f89787bd5426d8f3aae500a9613 Mon Sep 17 00:00:00 2001 From: Nathan Downs Date: Wed, 25 Sep 2019 14:50:07 -0700 Subject: [PATCH] Reintroduce Subresource Integrity hashes in the previews and as a separate option in the README --- README.md | 5 +++++ scripts/create-dist | 11 +++++++++++ scripts/preview | 3 ++- scripts/utils.js | 12 ++++++++++++ src/templates/preview.html | 2 +- 5 files changed, 31 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 30f93469..de09c2cb 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,11 @@ Use the following in the `` tag of your HTML document(s): This guarantees that you will always use the latest version of the library. +If, instead, you'd like to include the latest version explicitly, you can add the following tag: +```html + +``` + ### Download If instead you want to download a specific version, please look at the `gh-pages` branch, where you will find the built assets for both our latest and older versions. diff --git a/scripts/create-dist b/scripts/create-dist index fff1e4a9..e7382940 100755 --- a/scripts/create-dist +++ b/scripts/create-dist @@ -7,6 +7,7 @@ const fs = require('fs-extra'); const path = require('path'); const { spawnSync } = require('child_process'); +const { getIntegrityHash } = require('./utils'); function file(...which) { return path.join(__dirname, '..', ...which); @@ -55,6 +56,16 @@ fs.unlinkSync(distFile('twemoji.tmp.js')); fs.writeFileSync(distFile('twemoji.min.js'), `${copyright}\n${minifiedContents}`); fs.writeFileSync(distFile('twemoji.esm.js'), `${copyright}\n${minifiedContents}\nexport default twemoji;`); +const integrityHash = getIntegrityHash(distFile('twemoji.min.js')); +const { version } = require('../package.json'); + +function updateSriScriptReference(filename) { + const newScript = ` +