Normalize YouTube Shorts links to watch URLs

This commit is contained in:
Fisto
2026-09-17 13:34:10 +02:00
parent 52049bf186
commit 8c72def863
6 changed files with 197 additions and 8 deletions
+2 -1
View File
@@ -2238,7 +2238,8 @@
const host = url.hostname.replace(/^www\./, "");
if (host === "youtube.com" || host === "m.youtube.com") {
const id = url.searchParams.get("v");
const id =
url.searchParams.get("v") ?? /^\/shorts\/([A-Za-z0-9_-]+)/.exec(url.pathname)?.[1];
if (id) return `https://www.youtube.com/embed/${id}`;
}
if (host === "youtu.be") return `https://www.youtube.com/embed${url.pathname}`;