From 98075423f045502d760b1f61fedc196c538eccd3 Mon Sep 17 00:00:00 2001 From: Kibi Kelburton Date: Thu, 28 May 2026 19:28:22 +0200 Subject: [PATCH] bhi --- public/s/js/comments.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/public/s/js/comments.js b/public/s/js/comments.js index f5e0344..f696b13 100644 --- a/public/s/js/comments.js +++ b/public/s/js/comments.js @@ -1585,6 +1585,23 @@ class CommentSystem { href = href.href; } if (!href) return text || ''; + + // Strip playlist and tracking params from YouTube URLs so the embed regex always + // gets a clean URL (e.g. ?list=RDU-... breaks the regex / embed player). + if (/https?:\/\/(?:www\.)?(?:youtube\.com\/watch|youtu\.be\/)/i.test(href)) { + try { + const ytUrl = new URL(href); + const videoId = ytUrl.searchParams.get('v') || (ytUrl.hostname === 'youtu.be' ? ytUrl.pathname.slice(1) : null); + if (videoId) { + if (ytUrl.hostname === 'youtu.be') { + href = `https://youtu.be/${videoId}`; + } else { + href = `https://www.youtube.com/watch?v=${videoId}`; + } + } + } catch (e) { /* keep original href on parse failure */ } + } + const titleAttr = title ? ` title="${title}"` : ''; const isExternal = href.startsWith('http://') || href.startsWith('https://') || href.startsWith('//'); let isSameSite = false;