luci-base: luci.js: fix undefined "this" when /ubus/ is unavailable
authorJo-Philipp Wich <jo@mein.io>
Wed, 10 Jul 2019 11:30:52 +0000 (13:30 +0200)
committerJo-Philipp Wich <jo@mein.io>
Wed, 10 Jul 2019 11:30:52 +0000 (13:30 +0200)
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>
modules/luci-base/htdocs/luci-static/resources/luci.js

index 3e40b304b61c4cafebb36ce635dd55ab67bf087a..1f883ab80244c53f36b66b0e8ae6536f8f0f1db1 100644 (file)
                        }
 
                        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);