Fix exception in ping component

The exception happens when ConnectionRequestURL is not a valid URL.
This commit is contained in:
Zaid Abdulla committed 2021-01-06 05:09:09 -08:00
1 parent a40e4b863b
commit 5571ce96b4
1 file changed
+4 -2
+4 -2
View File
@@ -63,9 +63,11 @@ const component: ClosureComponent = (vn): Component => {
param = device["Device.ManagementServer.ConnectionRequestURL"]; param = device["Device.ManagementServer.ConnectionRequestURL"];
let h; let h;
if (param && param.value) { try {
const url = new URL(param.value[0]); const url = new URL(param.value[0]);
h = url.hostname; h = url.hostname;
} catch (err) {
// Ignore
} }
if (host !== h) { if (host !== h) {
@@ -77,7 +79,7 @@ const component: ClosureComponent = (vn): Component => {
} }
} }
return m("div", `Pinging ${host}:`); return m("div", host ? `Pinging ${host}:` : "");
}, },
}; };
}; };