From 46f5f6719dd491589d49cbd13d94d1dd8d0ca49a Mon Sep 17 00:00:00 2001
From: Christoph Reiter <reiter.christoph@gmail.com>
Date: Thu, 3 Oct 2019 11:32:58 +0200
Subject: [PATCH] Handle icons not returning valid svg

In case we get a html response because of our http fallback just return
the error icon instead.
---
 packages/common/vpu-icon.js | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/packages/common/vpu-icon.js b/packages/common/vpu-icon.js
index fa5b0f93..b427a79d 100644
--- a/packages/common/vpu-icon.js
+++ b/packages/common/vpu-icon.js
@@ -45,8 +45,10 @@ async function getSVGTextElement(name) {
         return unsafeHTML(errorIcon);
     }
     let text = await response.text();
-    if (text.indexOf('<svg') !== -1)
-        text = text.slice(text.indexOf('<svg'));
+    if (text.indexOf('<svg') === -1) {
+        return unsafeHTML(errorIcon);
+    }
+    text = text.slice(text.indexOf('<svg'));
     return unsafeHTML(text);
 }
 
@@ -86,10 +88,8 @@ class Icon extends LitElement {
 
     render() {
         let svg = getSVGTextElement(this.name);
-        let placeholder = unsafeHTML('<svg></svg>');
-
         return html`
-            ${until(svg, placeholder)}
+            ${until(svg)}
         `;
     }
 }
-- 
GitLab