Skip to content
Snippets Groups Projects
Unverified Commit a6d3ab51 authored by Anton Georgiev's avatar Anton Georgiev Committed by GitHub
Browse files

Merge pull request #6728 from pedrobmarin/youtube-url-formats

Matching extra YouTube video IDs from different URL formats
parents e5df6d97 a2146dfa
No related branches found
No related tags found
No related merge requests found
......@@ -15,11 +15,11 @@ const isUrlValid = (url) => {
const getUrlFromVideoId = id => (id ? `${YOUTUBE_PREFIX}${id}` : '');
// https://stackoverflow.com/questions/3452546/how-do-i-get-the-youtube-video-id-from-a-url
const videoIdFromUrl = (url) => {
const urlObj = new URL(url);
const params = new URLSearchParams(urlObj.search);
return params.get('v');
const regExp = /.*(?:youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=)([^#\&\?]*).*/;
const match = url.match(regExp);
return (match && match[1].length == 11) ? match[1] : false;
};
const startWatching = (url) => {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment