Skip to content

Commit 8aff40f

Browse files
committed
Update VideoPlayer.astro
1 parent 53aad1b commit 8aff40f

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

opensaas-sh/blog/src/components/VideoPlayer.astro

+5-5
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,20 @@ interface Props {
77
88
const { src, lgWidth = '55%', smWidth = '100%' } = Astro.props;
99
10-
// Function to check if the URL is a YouTube URL and extract the video ID
10+
// Function to check if the URL is a YouTube URL and, if so, extract the video ID
1111
function getYouTubeId(url: string): string | null {
1212
const regExp = /^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|&v=)([^#&?]*).*/;
1313
const match = url.match(regExp);
14-
return match && match[2].length === 11 ? match[2] : null;
14+
return match && match[2].length === 11 ? match[2] : null; // Note: all YouTube video IDs are 11 characters long.
1515
}
1616
17-
const youtubeId = getYouTubeId(src);
18-
const isYouTube = !!youtubeId;
17+
const youTubeId = getYouTubeId(src);
18+
const isYouTube = !!youTubeId;
1919
---
2020

2121
{isYouTube ? (
2222
<iframe
23-
src={`https://www.youtube.com/embed/${youtubeId}`}
23+
src={`https://www.youtube.com/embed/${youTubeId}`}
2424
title="YouTube video player"
2525
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
2626
allowfullscreen

0 commit comments

Comments
 (0)