I have a javascript code that will look for any YouTube link on the page and will replace those links with iFrame and embed the videos in the iFrame.
This work fine.
But sometimes, the youtube links have some stuff at the end of the link like this:
&t=3s
or &t=44s
etc
I need to be able to remove those as well but I can't fine a way to do this.
This is my code:
https://jsfiddle.net/6tv4uebw/
Code:
$(".indiContent").html(function (e, t) {
return t.replace(/http(?:s?):\/\/(?:www\.)?youtu(?:be\.com\/watch\?v=|\.be\/)([\w\-\_]*)(&(amp;)?[\w\?=]*)?/g, '<iframe width="100%" height="200" src="https://www.youtube.com/embed/$1" frameborder="0" allowfullscreen></iframe>')
});
Couls someone please advice on this issue?
Thanks in advance.