fix: youtube video id and mute param

This commit is contained in:
DIYgod
2024-06-06 00:18:24 +08:00
parent 0b8dd87511
commit 7a60e61c9d
+3 -3
View File
@@ -8,11 +8,11 @@ export const urlToIframe = (url?: string | null) => {
highQuality: "true",
bvid: url.match(/\/\/www.bilibili.com\/video\/(BV\w+)/)?.[1] || "",
}).toString()}`
} else if (url?.match(/\/\/www.youtube.com\/watch\?v=\w+/)) {
return `https://www.youtube-nocookie.com/embed/${url.match(/\/\/www.youtube.com\/watch\?v=(\w+)/)?.[1]}?${new URLSearchParams({
} else if (url?.match(/\/\/www.youtube.com\/watch\?v=[-\w]+/)) {
return `https://www.youtube-nocookie.com/embed/${url.match(/\/\/www.youtube.com\/watch\?v=([-\w]+)/)?.[1]}?${new URLSearchParams({
controls: "0",
autoplay: "1",
muted: "1",
mute: "1",
}).toString()}`
} else {
return null