From 7b1d7c8d6f0e0cf37a14ba95ef4ba27363f30300 Mon Sep 17 00:00:00 2001 From: Benedikt Maria Beckermann Date: Mon, 6 Nov 2023 15:08:31 +0100 Subject: [PATCH] Added additional check link matcher actually finds results --- backend/static/js/helper.js | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/backend/static/js/helper.js b/backend/static/js/helper.js index 16e24d56..cc8a4885 100644 --- a/backend/static/js/helper.js +++ b/backend/static/js/helper.js @@ -952,20 +952,23 @@ function getFormattedResultEntry(str, maxLength, column = undefined) { // // TODO: What if http occur somewhere inside a literal or a link? } else if (pos_http > 0) { - isLink = true; cpy = cpy.replace(/ /g, '_'); - link = cpy.match(/(https?:\/\/[a-zA-Z0-9.:%/#\?_-]+)/g)[0]; - checkLink = link.toLowerCase(); - if (checkLink.endsWith('jpg') || checkLink.endsWith('png') || checkLink.endsWith('gif') || checkLink.endsWith('jpeg') || checkLink.endsWith('svg')) { - str = ""; - linkStart = ''; - linkEnd = ''; - } else if (checkLink.endsWith('pdf') || checkLink.endsWith('doc') || checkLink.endsWith('docx')) { - linkStart = ' '; - linkEnd = ''; - } else { - linkStart = ' '; - linkEnd = ''; + link_match = cpy.match(/(https?:\/\/[a-zA-Z0-9.:%/#\?_-]+)/g); + if(link_match != null) { + isLink = true; + link = link_match[0]; + checkLink = link.toLowerCase(); + if (checkLink.endsWith('jpg') || checkLink.endsWith('png') || checkLink.endsWith('gif') || checkLink.endsWith('jpeg') || checkLink.endsWith('svg')) { + str = ""; + linkStart = ''; + linkEnd = ''; + } else if (checkLink.endsWith('pdf') || checkLink.endsWith('doc') || checkLink.endsWith('docx')) { + linkStart = ' '; + linkEnd = ''; + } else { + linkStart = ' '; + linkEnd = ''; + } } }