Embed doesn't recognise some youtube urls
for example: https://www.youtube.com/watch?v=UTFJDjBKgWk&feature=youtu.be
looks like the &feature=youtu.be url param, prevents from Embed to recognise this is as a youtube link
Potential regex solution:
/(?:https?:\/\/)?(?:www\.)?(?:(?:youtu\.be\/)|(?:youtube\.com)\/(?:v\/|u\/\w\/|embed\/|watch))(?:(?:\?v=)?([^#&?=]*))?((?:[?&]\w*=\w*(\.\w*)?)*)/
Yeah, there are more of those. Another example: https://www.youtube.com/watch?v=z0qW9P-uYfM&list=RDz0qW9P-uYfM&start_radio=1
...even this doesn't work: https://www.youtube.com/watch?v=z0qW9P-uYfM&
Faced the same issue,
@orbachar regex worked with his example, but not for this one: https://www.youtube.com/watch?v=sbGjr_awePE&t=3s&ab_channel=TED-Ed
fixed by changing regex in config:
embed: {
class: Embed,
config: {
services: {
youtube: {
regex: /(?:https?:\/\/)?(?:www\.)?(?:(?:youtu\.be\/)|(?:youtube\.com)\/(?:v\/|u\/.\/|embed\/|watch))(?:(?:\?v=)?([^#&?=]*))?((?:[?&].*=.*)*)/,
},
},
},
}
Basically I changed all \w in the default youtube regex (given here: https://github.com/editor-js/embed/blob/master/src/services.js) by . since \w does not catch dots(.), hyphens (-) or other special characters which can appear in youtube urls.
Embed needs a more robust regex by default. In a real-world scenario, it's not possible to expect the end user to always paste a YT URL without additional query string params.