diff --git a/diagnostic/index.html b/diagnostic/index.html
index bd2d80b..c2eb367 100644
--- a/diagnostic/index.html
+++ b/diagnostic/index.html
@@ -3558,16 +3558,26 @@
function linkifyText(escaped) {
// URLs in escaped HTML erkennen und ersetzen
- return escaped.replace(/(https?:\/\/[^\s<&]+)/g, function(url) {
- const decoded = url.replace(/&/g, '&');
- const pathname = new URL(decoded).pathname;
+ return escaped.replace(/(https?:\/\/[^\s<&]+)/g, function(match) {
+ // Satzzeichen am Ende gehoeren nicht zur URL: "(http://host:8080)," —
+ // sonst wirft new URL() und die ganze Nachricht wird nicht angezeigt.
+ let url = match, rest = '';
+ while (/[.,;:!?)\]'"]$/.test(url)) {
+ // ")" gehoert zur URL, wenn sie selbst eine "(" offen hat (Wikipedia)
+ if (url.endsWith(')') && url.split('(').length >= url.split(')').length) break;
+ rest = url.slice(-1) + rest;
+ url = url.slice(0, -1);
+ }
+ let pathname;
+ try { pathname = new URL(url.replace(/&/g, '&')).pathname; }
+ catch (e) { return match; } // keine gueltige URL: als Text lassen
if (MEDIA_IMG.test(pathname)) {
- return `${url}
`;
+ return `${url}
` + rest;
}
if (MEDIA_VID.test(pathname)) {
- return `${url}`;
+ return `${url}` + rest;
}
- return `${url}`;
+ return `${url}` + rest;
});
}