From: Jo-Philipp Wich Date: Wed, 10 Jul 2019 11:30:52 +0000 (+0200) Subject: luci-base: luci.js: fix undefined "this" when /ubus/ is unavailable X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=69e5488c139f249fcf785d4ba170a90ed0e7f33c;p=oweals%2Fluci.git 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 --- 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);