support youtu.be links

This commit is contained in:
hzrd149 2023-06-08 14:52:39 -04:00
parent dcfc011dea
commit cc77e0d089

View File

@ -21,7 +21,8 @@ export function renderYoutubeUrl(match: URL) {
const { youtubeRedirect } = appSettings.value;
const videoId = match.searchParams.get("v");
var videoId = match.searchParams.get("v");
if (match.hostname === "youtu.be") videoId = match.pathname.split("/")[1];
if (!videoId) throw new Error("cant find video id");
const embedUrl = new URL(`/embed/${videoId}`, youtubeRedirect || "https://youtube.com");