From 270773d6ba382c6fdbdb29d9b739790b17437653 Mon Sep 17 00:00:00 2001 From: Nikhil Tanwar <2002nikhiltanwar@gmail.com> Date: Fri, 21 Jan 2022 22:51:03 +0530 Subject: [PATCH] Add undefined check for humanFriendlyTitle humanFriendlyTitle() now returns an empty string if title is undefined which is handled in loadAndDisplayOptions() --- static/skin/index.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/static/skin/index.js b/static/skin/index.js index 70cc86763..ef4bc48ca 100644 --- a/static/skin/index.js +++ b/static/skin/index.js @@ -53,8 +53,12 @@ }; const humanFriendlyTitle = (title) => { - title = title.replace(/_/g, ' '); - return htmlEncode(title[0].toUpperCase() + title.slice(1)); + if (typeof title === 'string' && title.length > 0) { + title = title.replace(/_/g, ' '); + return htmlEncode(title[0].toUpperCase() + title.slice(1)); + } else { + return ''; + } } function htmlEncode(str) { @@ -238,7 +242,8 @@ data.querySelectorAll('entry').forEach(entry => { const title = getInnerHtml(entry, 'title'); const value = getInnerHtml(entry, valueEntryNode); - optionStr += ``; + const hfTitle = humanFriendlyTitle(title); + optionStr += (hfTitle != '') ? `` : ''; }); document.querySelector(nodeQuery).innerHTML += optionStr; });