diff --git a/funnel/assets/js/utils/embedvideo.js b/funnel/assets/js/utils/embedvideo.js index 1e677c420..88a65e588 100644 --- a/funnel/assets/js/utils/embedvideo.js +++ b/funnel/assets/js/utils/embedvideo.js @@ -8,18 +8,21 @@ const Video = { */ getVideoTypeAndId(url) { const regexMatch = url.match( - /(http:|https:|)\/\/(player.|www.)?(y2u\.be|vimeo\.com|youtu(be\.com|\.be|be\.googleapis\.com))\/(video\/|embed\/|live\/|watch\?v=|v\/)?([A-Za-z0-9._%-]*)(&\S+)?(\?h=([^&]+))?/ + /(http:|https:|)\/\/(player.|www.)?(?y2u\.be|vimeo\.com|youtu(be\.com|\.be|be\.googleapis\.com))\/(video\/|embed\/|live\/|watch\?v=|v\/)?(?[A-Za-z0-9._%-]*)(&\S+)?(\?h=(?[^&]+))?/ ); let type = ''; if (regexMatch && regexMatch.length > 5) { - if (regexMatch[3].indexOf('youtu') > -1 || regexMatch[3].indexOf('y2u') > -1) { + if ( + regexMatch.groups.service.indexOf('youtu') > -1 || + regexMatch.groups.service.indexOf('y2u') > -1 + ) { type = 'youtube'; - } else if (regexMatch[3].indexOf('vimeo') > -1) { + } else if (regexMatch.groups.service.indexOf('vimeo') > -1) { type = 'vimeo'; return { type, - videoId: regexMatch[6], - paramId: regexMatch[9], + videoId: regexMatch.groups.videoId, + paramId: regexMatch.groups.paramId, }; } return { @@ -38,7 +41,9 @@ const Video = { if (type === 'youtube') { videoEmbedUrl = ``; } else if (type === 'vimeo') { - videoEmbedUrl = ``; + videoEmbedUrl = ``; } if (videoEmbedUrl) { videoWrapper.innerHTML = videoEmbedUrl;