Enable contenthash in filename for dynamic assets (#20813)

This should solve the main problem of dynamic assets getting stale after
a version upgrade. Everything not affected will use query-string based
cache busting, which includes files loaded via HTML or worker scripts.
This commit is contained in:
silverwind 2022-08-23 14:58:04 +02:00 committed by GitHub
parent 0a9ed54abb
commit 56220515fc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 1102 additions and 802 deletions

View file

@ -1,5 +1,6 @@
import {
basename, extname, isObject, uniq, stripTags, joinPaths, parseIssueHref, strSubMatch, prettyNumber,
basename, extname, isObject, uniq, stripTags, joinPaths, parseIssueHref, strSubMatch,
prettyNumber, parseUrl,
} from './utils.js';
test('basename', () => {
@ -108,3 +109,15 @@ test('prettyNumber', () => {
expect(prettyNumber(12345678, 'be-BE')).toEqual('12 345 678');
expect(prettyNumber(12345678, 'hi-IN')).toEqual('1,23,45,678');
});
test('parseUrl', () => {
expect(parseUrl('').pathname).toEqual('/');
expect(parseUrl('/path').pathname).toEqual('/path');
expect(parseUrl('/path?search').pathname).toEqual('/path');
expect(parseUrl('/path?search').search).toEqual('?search');
expect(parseUrl('/path?search#hash').hash).toEqual('#hash');
expect(parseUrl('https://localhost/path').pathname).toEqual('/path');
expect(parseUrl('https://localhost/path?search').pathname).toEqual('/path');
expect(parseUrl('https://localhost/path?search').search).toEqual('?search');
expect(parseUrl('https://localhost/path?search#hash').hash).toEqual('#hash');
});