Actually fixed regex.

This commit is contained in:
Tobias Theuer 2017-03-15 03:55:22 +01:00
parent 7e7da76006
commit ce3ac634cb

View file

@ -209,11 +209,11 @@ plugins.factory('userPlugins', function() {
* See: https://developers.google.com/youtube/player_parameters
*/
var youtubePlugin = new UrlPlugin('YouTube video', function(url) {
var regex = /^.*(youtu\.be\/|v\/|u\/\w\/|embed\/|watch\?v=|\&v=)([^#\&\?]*).*/i,
var regex = /(?:youtube\.com\/(?:[^\/]+\/.+\/|(?:v|e(?:mbed)?)\/|.*[?&]v=)|youtu\.be\/)([^"&?\/ ]{11})/i,
match = url.match(regex);
if (match){
var token = match[2],
var token = match[1],
embedurl = "https://www.youtube.com/embed/" + token + "?html5=1&iv_load_policy=3&modestbranding=1&rel=0",
element = angular.element('<iframe></iframe>')
.attr('src', embedurl)