From bf2e858c2446b3aed5895d726a1d6f27dd6790af Mon Sep 17 00:00:00 2001 From: Marvin W Date: Mon, 1 Aug 2016 23:25:29 +0200 Subject: [PATCH] Make sure hopglass does not break when server reports nodes without hostname. (#58) --- lib/nodelist.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/nodelist.js b/lib/nodelist.js index efcaf80..ee1409c 100644 --- a/lib/nodelist.js +++ b/lib/nodelist.js @@ -21,7 +21,11 @@ define(["sorttable", "virtual-dom", "numeral"], function (SortTable, V, numeral) var headings = [{ name: "Knoten", sort: function (a, b) { - return a.nodeinfo.hostname.localeCompare(b.nodeinfo.hostname) + var aname = typeof a.nodeinfo.hostname === "string" ? a.nodeinfo.hostname : a.nodeinfo.node_id + var bname = typeof b.nodeinfo.hostname === "string" ? b.nodeinfo.hostname : b.nodeinfo.node_id + if (typeof aname === "string" && typeof bname === "string") + return aname.localeCompare(bname) + return typeof aname === "string" ? 1 : typeof bname === "string" ? -1 : 0 }, reverse: false },