Skip to content

Commit f871768

Browse files
Apply suggested fix to src/components/youtube-transformer.js from Copilot Autofix
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
1 parent 4cb0d52 commit f871768

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

src/components/youtube-transformer.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,15 @@ const YouTubeTransformer = {
2525
const videoId = isShort
2626
? urlObj.pathname.split("/").filter(Boolean).pop()
2727
: urlObj.searchParams.get("v");
28+
const validVideoId = typeof videoId === "string" && /^[A-Za-z0-9_-]{11}$/.test(videoId);
29+
30+
if (!validVideoId) {
31+
return "";
32+
}
2833

2934
return `
3035
<iframe
31-
src="https://www.youtube.com/embed/${videoId}"
36+
src="https://www.youtube.com/embed/${encodeURIComponent(videoId)}"
3237
style="width:100%; aspect-ratio:16/9; border:0;"
3338
allowfullscreen
3439
></iframe>

0 commit comments

Comments
 (0)