Skip to content

Commit 1650089

Browse files
authored
Create getYoutubeVideoId.js
1 parent 5d498a8 commit 1650089

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
const getYoutubeEmbedUrl = (url) => {
2+
const youtubeVideoId = url.match(
3+
/^.*(?:(?:youtu\.be\/|v\/|vi\/|u\/\w\/|embed\/)|(?:(?:watch)?\?v(?:i)?=|\&v(?:i)?=))([^#\&\?]*).*/,
4+
);
5+
6+
return `https://www.youtube.com/embed/${youtubeVideoId[1]}`;
7+
};

0 commit comments

Comments
 (0)