From 803f17fde4b2bd6eefd58f3c69778cfc8b71fba0 Mon Sep 17 00:00:00 2001 From: Teh PeGaSuS Date: Wed, 22 Apr 2026 23:21:43 +0200 Subject: [PATCH] Update app.js --- app.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/app.js b/app.js index a7e2bea..ef0a5b3 100644 --- a/app.js +++ b/app.js @@ -284,15 +284,15 @@ function ansiToHtml(text) { } out += s.slice(last); if (spans > 0) out += ''.repeat(spans); - // Linkify — detect images/video for inline preview toggle - return out.replace(/(https?:\/\/[^\s<>"&]+)/g, (url) => { - const clean = url.replace(/&/g,'&'); - const isImg = /\.(png|jpe?g|gif|webp|svg|bmp)(\?.*)?$/i.test(clean); - const isVid = /\.(mp4|webm|ogv|mov)(\?.*)?$/i.test(clean); - const preview = (isImg || isVid) - ? `` + // Linkify URLs; match through & so query strings aren't cut short + return out.replace(/https?:\/\/(?:[^\s<>"\']|&)+/g, (url) => { + const href = url.replace(/&/g, '&'); + const isImg = /\.(png|jpe?g|gif|webp|svg|bmp)(\?.*)?$/i.test(href); + const isVid = /\.(mp4|webm|ogv|mov)(\?.*)?$/i.test(href); + const btn = (isImg || isVid) + ? ` ` : ''; - return `${url}${preview}`; + return `${url}${btn}`; }); }