Przeglądaj źródła

HUE-6566 [frontend] Prevent JS error on empty URLs for open.link

Enrico Berti 8 lat temu
rodzic
commit
70c37c4
1 zmienionych plików z 9 dodań i 4 usunięć
  1. 9 4
      desktop/core/src/desktop/templates/hue.mako

+ 9 - 4
desktop/core/src/desktop/templates/hue.mako

@@ -1036,10 +1036,15 @@ ${ smart_unicode(login_modal(request).content) | n,unicode }
         });
         });
 
 
         huePubSub.subscribe('open.link', function (href) {
         huePubSub.subscribe('open.link', function (href) {
-          if (href.startsWith('/') && !href.startsWith('/hue')){
-            page('/hue' + href);
-          } else {
-            page(href);
+          if (href) {
+            if (href.startsWith('/') && !href.startsWith('/hue')){
+              page('/hue' + href);
+            } else {
+              page(href);
+            }
+          }
+          else {
+            console.warn('Received an open.link without href.')
           }
           }
         });
         });
       };
       };