diff options
author | silverwind <me@silverwind.io> | 2022-08-23 14:58:04 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-23 20:58:04 +0800 |
commit | 56220515fc882943e366fafbce4d5b2b3ccee702 (patch) | |
tree | d64bffc3a9d13ce01bf56aedc896923aa4af0acf /web_src/js/utils.test.js | |
parent | 0a9ed54abbe8b6837dcb22a35b744c11f410421f (diff) | |
download | gitea-56220515fc882943e366fafbce4d5b2b3ccee702.tar.gz gitea-56220515fc882943e366fafbce4d5b2b3ccee702.zip |
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.
Diffstat (limited to 'web_src/js/utils.test.js')
-rw-r--r-- | web_src/js/utils.test.js | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/web_src/js/utils.test.js b/web_src/js/utils.test.js index ba5335e3e4..90fb08e8e4 100644 --- a/web_src/js/utils.test.js +++ b/web_src/js/utils.test.js @@ -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'); +}); |