diff --git a/assets/javascripts/audit_log.js b/assets/javascripts/audit_log.js index 088c556608ef..bc99488ee695 100644 --- a/assets/javascripts/audit_log.js +++ b/assets/javascripts/audit_log.js @@ -191,6 +191,7 @@ function renderScheduledProductSettings(settings) { const keyTd = document.createElement('td'); const valueTd = document.createElement('td'); keyTd.append(key); + valueTd.style.whiteSpace = 'pre-wrap'; valueTd.append(renderHttpUrlAsLink(value)); tr.append(keyTd, valueTd); tbody.append(tr); diff --git a/assets/javascripts/openqa.js b/assets/javascripts/openqa.js index 8c427aee5dba..4ee696015514 100644 --- a/assets/javascripts/openqa.js +++ b/assets/javascripts/openqa.js @@ -577,19 +577,45 @@ function renderComments(row) { } function renderHttpUrlAsLink(value) { - const span = document.createElement('span'); - for (let match; (match = value.match(/https?:\/\/[^\s,]*/)); ) { - const url = match[0]; - const link = document.createElement('a'); - link.href = url; - link.target = 'blank'; - link.appendChild(document.createTextNode(url)); - span.appendChild(document.createTextNode(value.substr(0, match.index))); - span.appendChild(link); - value = value.substr(match.index + url.length); + if (!value) { + return value; + } + if (Array.isArray(value)) { + const fragment = document.createDocumentFragment(); + value.forEach((item, index) => { + fragment.append(renderHttpUrlAsLink(item)); + if (index < value.length - 1) { + fragment.append(', '); // Add a separator between items + } + }); + return fragment; + } + if (typeof value !== 'string') { + value = String(value); + } + const urlRegex = /https?:\/\/[^\s,]*/g; + const matches = value.match(urlRegex); + if (matches) { + const fragment = document.createDocumentFragment(); + let lastIndex = 0; + for (const match of matches) { + const index = value.indexOf(match, lastIndex); + if (index > lastIndex) { + fragment.append(value.substring(lastIndex, index)); + } + const a = document.createElement('a'); + a.href = match; + a.textContent = match; + fragment.append(a); + lastIndex = index + match.length; + } + if (lastIndex < value.length) { + fragment.append(value.substring(lastIndex)); + } + return fragment; + } else { + return value; } - span.appendChild(document.createTextNode(value)); - return span; } function getXhrError(jqXHR, textStatus, errorThrown) {