We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent bfa854d commit 0294c37Copy full SHA for 0294c37
1 file changed
src/components/youtube-transformer.js
@@ -25,10 +25,15 @@ const YouTubeTransformer = {
25
const videoId = isShort
26
? urlObj.pathname.split("/").filter(Boolean).pop()
27
: urlObj.searchParams.get("v");
28
+ const validVideoId = typeof videoId === "string" && /^[A-Za-z0-9_-]{11}$/.test(videoId);
29
+
30
+ if (!validVideoId) {
31
+ return "";
32
+ }
33
34
return `
35
<iframe
- src="https://www.youtube.com/embed/${videoId}"
36
+ src="https://www.youtube.com/embed/${encodeURIComponent(videoId)}"
37
style="width:100%; aspect-ratio:16/9; border:0;"
38
allowfullscreen
39
></iframe>
0 commit comments