[FIX] Parse image URL only if it's not empty (#1372)

This commit is contained in:
Diego Mello 2019-11-07 11:59:17 -03:00 committed by GitHub
parent 38523509e0
commit 5e4ce8feac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 4 deletions

View File

@ -9,10 +9,12 @@ export default urls => urls.filter(url => url.meta && !url.ignoreParse).map((url
decodedOgImage = meta.ogImage.replace(/&/g, '&');
}
tmp.image = decodedOgImage || meta.twitterImage || meta.oembedThumbnailUrl;
if (tmp.image.indexOf('//') === 0) {
tmp.image = `${ url.parsedUrl.protocol }${ tmp.image }`;
} else if (tmp.image.indexOf('/') === 0 && (url.parsedUrl && url.parsedUrl.host)) {
tmp.image = `${ url.parsedUrl.protocol }//${ url.parsedUrl.host }${ tmp.image }`;
if (tmp.image) {
if (tmp.image.indexOf('//') === 0) {
tmp.image = `${ url.parsedUrl.protocol }${ tmp.image }`;
} else if (tmp.image.indexOf('/') === 0 && (url.parsedUrl && url.parsedUrl.host)) {
tmp.image = `${ url.parsedUrl.protocol }//${ url.parsedUrl.host }${ tmp.image }`;
}
}
tmp.url = url.url;
return tmp;