summaryrefslogtreecommitdiffhomepage
path: root/modules
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2019-09-14 17:44:32 +0200
committerJo-Philipp Wich <jo@mein.io>2019-09-14 17:44:32 +0200
commit2e206861aec48b2ed6fc475e51d755594dd5d9f3 (patch)
tree0b73fc687535d44ce5447d0878e0f76edfb16b1f /modules
parent208bf47a33d5b6f1febd51785958ffefe25afc64 (diff)
luci-base: luci.js: append version when dynamically loading classes
This allows for some naive cache busting when the LuCI version changes, to avoid loading outdated classes from cache. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'modules')
-rw-r--r--modules/luci-base/htdocs/luci-static/resources/luci.js11
1 files changed, 8 insertions, 3 deletions
diff --git a/modules/luci-base/htdocs/luci-static/resources/luci.js b/modules/luci-base/htdocs/luci-static/resources/luci.js
index 687ac0e67..bcc6870bd 100644
--- a/modules/luci-base/htdocs/luci-static/resources/luci.js
+++ b/modules/luci-base/htdocs/luci-static/resources/luci.js
@@ -575,8 +575,13 @@
__init__: function(env) {
document.querySelectorAll('script[src*="/luci.js"]').forEach(function(s) {
- if (env.base_url == null || env.base_url == '')
- env.base_url = s.getAttribute('src').replace(/\/luci\.js(?:\?v=[^?]+)?$/, '');
+ if (env.base_url == null || env.base_url == '') {
+ var m = (s.getAttribute('src') || '').match(/^(.*)\/luci\.js(?:\?v=([^?]+))?$/);
+ if (m) {
+ env.base_url = m[1];
+ env.resource_version = m[2];
+ }
+ }
});
if (env.base_url == null)
@@ -693,7 +698,7 @@
return classes[name];
}
- url = '%s/%s.js'.format(L.env.base_url, name.replace(/\./g, '/'));
+ url = '%s/%s.js%s'.format(L.env.base_url, name.replace(/\./g, '/'), (L.env.resource_version ? '?v=' + L.env.resource_version : ''));
from = [ name ].concat(from);
var compileClass = function(res) {