Searching in JavaScript for a youtube video url is not too difficult with regex using the regex syntax below. This will match youtube urls as both https://www.youtube.com/watch?v=LyfI8sfwwer2 and https://youtu.be/puSK4XFHr8I?si=Yy0IQmlhE0r4Ns.
https://www.youtube.com/watch?v=LyfI8sfwwer2
https://youtu.be/puSK4XFHr8I?si=Yy0IQmlhE0r4Ns