Closed vanhumbeecka closed 4 years ago
This is caused by these lines of code:
id() {
const regExp = /^https:\/\/www\.youtube\.com\/watch\?v=(.+)$/;
return regExp.exec(this.url)[1];
},
Should be updated like so:
id() {
try {
const regExp = /^https:\/\/www\.youtube\.com\/watch\?v=(.+)$/;
return regExp.exec(this.url)[1];
} catch (err) {
throw 'Youtube url in wrong format. Must be written as https://wwww.youtube.com/watch?v=1234';
return 0;
}
},
@unr, @vanhumbeecka Thanks. I will change regExp
a bit to handle cases with URL that starts with:
https://www.youtube-nocookie.com
. Also in the next minor version the noCookie
prop will be introduced, which will generate appropriate url for the <iframe />
.
See 29a6ad58163af163c45ed7f20f461e2028d96b1d.
Notice: you should not pass URL with /embed/
part. Just pass a direct link to the video itself:
https://www.youtube.com/watch?v=2u_pZ-SgACk
.
@vanhumbeecka, @unr, Fixed in @1.3.0-beta.0
. Just pass noCookie
prop with true
value.
Can we close the issue? 🤔
Happens when I pass the following YouTube URL: https://www.youtube-nocookie.com/embed/MTk-Hwr15ao.
Does not happen when using a normal YouTube URL, like: https://www.youtube.com/watch?v=2u_pZ-SgACk.
Not sure if this qualifies as a bug or a feature.