diff options
author | Jo-Philipp Wich <jo@mein.io> | 2019-07-10 13:30:52 +0200 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2019-07-10 13:30:52 +0200 |
commit | 69e5488c139f249fcf785d4ba170a90ed0e7f33c (patch) | |
tree | 5e82b8065e129afef5dce1a72b71f5efe401c7b6 /modules/luci-base | |
parent | 1991b4ae64af79e3cd346d8383d3a586a16f6b80 (diff) |
luci-base: luci.js: fix undefined "this" when /ubus/ is unavailable
Fixes: #2850
Fixes: 66dfe64ca ("luci-base: luci.js: cache determined RPC base url in session storage")
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'modules/luci-base')
-rw-r--r-- | modules/luci-base/htdocs/luci-static/resources/luci.js | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/modules/luci-base/htdocs/luci-static/resources/luci.js b/modules/luci-base/htdocs/luci-static/resources/luci.js index 3e40b304b..1f883ab80 100644 --- a/modules/luci-base/htdocs/luci-static/resources/luci.js +++ b/modules/luci-base/htdocs/luci-static/resources/luci.js @@ -762,10 +762,12 @@ } if (rpcBaseURL == null) { + var rpcFallbackURL = this.url('admin/ubus'); + rpcBaseURL = Request.get('/ubus/').then(function(res) { - return (rpcBaseURL = (res.status == 400) ? '/ubus/' : this.url('admin/ubus')); + return (rpcBaseURL = (res.status == 400) ? '/ubus/' : rpcFallbackURL); }, function() { - return (rpcBaseURL = L.url('admin/ubus')); + return (rpcBaseURL = rpcFallbackURL); }).then(function(url) { try { window.sessionStorage.setItem('rpcBaseURL', url); |