1
0
mirror of https://github.com/twitter/twemoji.git synced 2024-07-03 03:18:58 +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:
Nathan Downs 2019-05-29 17:08:37 -07:00
parent 523e8f703c
commit e789942c00
3 changed files with 6 additions and 10 deletions

View File

@ -51,19 +51,15 @@ fs.unlinkSync(file('twemoji.tmp.js'));
fs.writeFileSync(file('twemoji.min.js'), `${copyright}\n${minifiedContents}`); fs.writeFileSync(file('twemoji.min.js'), `${copyright}\n${minifiedContents}`);
fs.writeFileSync(file('twemoji.esm.js'), `${copyright}\n${minifiedContents}\nexport default twemoji;`); 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'); const { version } = require('../../package.json');
function updateScript(filename) { 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( fs.writeFileSync(
filename, 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')); updateScript(file('..', 'README.md'));

View File

@ -25,7 +25,7 @@
vertical-align: -0.1em; vertical-align: -0.1em;
} }
</style> </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> </head>
<body> <body>
<ul class="emoji-list"> <ul class="emoji-list">

View File

@ -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): Use the following in the `<head>` tag of your HTML document(s):
```html ```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 ## Breaking changes in V2