mirror of
https://github.com/twitter/twemoji.git
synced 2024-06-15 03:35:16 +00:00
Revert adding SRI hashes to our recommended script tags - the way we handle resources via MaxCDN cache would mean we'd break old script tags when we publish (and the local cached file is evicted)
This commit is contained in:
parent
523e8f703c
commit
e789942c00
@ -51,19 +51,15 @@ fs.unlinkSync(file('twemoji.tmp.js'));
|
||||
fs.writeFileSync(file('twemoji.min.js'), `${copyright}\n${minifiedContents}`);
|
||||
fs.writeFileSync(file('twemoji.esm.js'), `${copyright}\n${minifiedContents}\nexport default twemoji;`);
|
||||
|
||||
const algorithm = 'sha384';
|
||||
const digest = spawnSync('openssl', ['dgst', `-${algorithm}`, '-binary', file('twemoji.min.js')]);
|
||||
if (digest.status || digest.signal){
|
||||
throw new Error(digest.stderr.toString('utf8'));
|
||||
}
|
||||
const integrityHash = digest.stdout.toString('base64');
|
||||
const { version } = require('../../package.json');
|
||||
|
||||
function updateScript(filename) {
|
||||
const newScript = `<script src="https://twemoji.maxcdn.com/2/twemoji.min.js?${version}" integrity="${algorithm}-${integrityHash}"`
|
||||
const newScript = `<script src="https://twemoji.maxcdn.com/2/twemoji.min.js?${version}"`;
|
||||
fs.writeFileSync(
|
||||
filename,
|
||||
fs.readFileSync(filename).toString('utf8').replace(/<script src="[^ ]*" integrity="[^ ]*"/, newScript));
|
||||
fs.readFileSync(filename)
|
||||
.toString('utf8')
|
||||
.replace(/<script src="[^ ]*twemoji.min.js[^ ]*"/, newScript));
|
||||
}
|
||||
|
||||
updateScript(file('..', 'README.md'));
|
||||
|
@ -25,7 +25,7 @@
|
||||
vertical-align: -0.1em;
|
||||
}
|
||||
</style>
|
||||
<script src="https://twemoji.maxcdn.com/2/twemoji.min.js?12.0.3" integrity="sha384-7+Exj+H0lyDecZJgGh5OY9weffMWB5mR0eabC91knEMUphmKHRmU2gN6JEQqJW3Q" crossorigin="anonymous"></script>
|
||||
<script src="https://twemoji.maxcdn.com/2/twemoji.min.js?12.0.3" crossorigin="anonymous"></script>
|
||||
</head>
|
||||
<body>
|
||||
<ul class="emoji-list">
|
||||
|
@ -17,7 +17,7 @@ The folks over at [MaxCDN](https://www.maxcdn.com) have graciously provided CDN
|
||||
|
||||
Use the following in the `<head>` tag of your HTML document(s):
|
||||
```html
|
||||
<script src="https://twemoji.maxcdn.com/2/twemoji.min.js?12.0.3" integrity="sha384-7+Exj+H0lyDecZJgGh5OY9weffMWB5mR0eabC91knEMUphmKHRmU2gN6JEQqJW3Q" crossorigin="anonymous"></script>
|
||||
<script src="https://twemoji.maxcdn.com/2/twemoji.min.js?12.0.3" crossorigin="anonymous"></script>
|
||||
```
|
||||
|
||||
## Breaking changes in V2
|
||||
|
Loading…
Reference in New Issue
Block a user