Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
writeOut = e => {
if (this.props.field.get("extraInfo")) {
try {
const { id, provider, mediaType } = urlParser.parse(e.target.value);
const videoInfo = urlParser.parse(e.target.value);
this.props.onChange({
url: e.target.value,
id: id,
mediaType: mediaType,
imageURL: urlParser.create({
videoInfo,
format: "longImage",
params: { imageQuality: "maxresdefault" }
})
});
} catch (err) {
console.error("Not a valid Youtube URL");
this.props.onChange(e.target.value);
}
} else {
this.props.onChange(e.target.value);
}
};
searchVideo() {
if (this.match && this.match.videoURL) {
const video = urlParser.parse(this.match.videoURL);
let embedURL = urlParser.create({
videoInfo: video,
params: 'internal',
format: 'embed'
});
if (embedURL) {
if (embedURL.startsWith('//')) {
embedURL = 'https:' + embedURL;
}
this.videoSafeURL = this.sanitizer.bypassSecurityTrustResourceUrl(embedURL);
}
}
}
}
getImage(videoInfo) {
if (videoInfo) {
return urlParser.create({
videoInfo,
format: "longImage",
params: { imageQuality: "maxresdefault" }
});
}
}