summaryrefslogtreecommitdiffstats
path: root/web_src/js/utils.js
diff options
context:
space:
mode:
authorsilverwind <me@silverwind.io>2022-08-23 14:58:04 +0200
committerGitHub <noreply@github.com>2022-08-23 20:58:04 +0800
commit56220515fc882943e366fafbce4d5b2b3ccee702 (patch)
treed64bffc3a9d13ce01bf56aedc896923aa4af0acf /web_src/js/utils.js
parent0a9ed54abbe8b6837dcb22a35b744c11f410421f (diff)
downloadgitea-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.js')
-rw-r--r--web_src/js/utils.js5
1 files changed, 5 insertions, 0 deletions
diff --git a/web_src/js/utils.js b/web_src/js/utils.js
index e9cd39032d..343ee4a03b 100644
--- a/web_src/js/utils.js
+++ b/web_src/js/utils.js
@@ -97,3 +97,8 @@ export function prettyNumber(num, locale = 'en-US') {
const {format} = new Intl.NumberFormat(locale);
return format(num);
}
+
+// parse a URL, either relative '/path' or absolute 'https://localhost/path'
+export function parseUrl(str) {
+ return new URL(str, str.startsWith('http') ? undefined : window.location.origin);
+}