Normalize YouTube Shorts links to watch URLs
This commit is contained in:
+2
-1
@@ -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}`;
|
||||
|
||||
Reference in New Issue
Block a user