diff --git a/src/embed-video.service.ts b/src/embed-video.service.ts index 889dd44..3d0ad64 100644 --- a/src/embed-video.service.ts +++ b/src/embed-video.service.ts @@ -203,7 +203,13 @@ export class EmbedVideoService { private detectYoutube(url: any): string { if (url.hostname.indexOf('youtube.com') > -1) { - return url.search.split('=')[1]; + var video_id = url.search.split('v=')[1]; + var ampersandPosition = video_id.indexOf('&'); + if(ampersandPosition != -1) { + video_id = video_id.substring(0, ampersandPosition); + } + + return video_id; } if (url.hostname === 'youtu.be') {