Skip to content

Commit

Permalink
Fixed regex to also recognize shortened urls
Browse files Browse the repository at this point in the history
  • Loading branch information
kaffeed committed May 12, 2020
1 parent c3055cf commit 65470f3
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion modules/apis/YouTubePlayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export class YouTubePlayer
parseVideoId(url)
{
if (url === undefined) { return ''; }
const regexMatch = url.trim().match(/.*youtube\.com\/watch\?v=(.{11}).*/);
const regexMatch = url.trim().match(/(?:https?:\/{2})?(?:w{3}\.)?youtu(?:be)?\.(?:com|be)(?:\/watch\?v=|\/)([^\s&]+)/);
return regexMatch !== null ? regexMatch[1] : null;
}

Expand Down

0 comments on commit 65470f3

Please sign in to comment.