From 5e4ce8feacb26dcd5c75cd9267d878c6667fb391 Mon Sep 17 00:00:00 2001 From: Diego Mello Date: Thu, 7 Nov 2019 11:59:17 -0300 Subject: [PATCH] [FIX] Parse image URL only if it's not empty (#1372) --- app/lib/methods/helpers/parseUrls.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/lib/methods/helpers/parseUrls.js b/app/lib/methods/helpers/parseUrls.js index ec2397a3..d49c54c4 100644 --- a/app/lib/methods/helpers/parseUrls.js +++ b/app/lib/methods/helpers/parseUrls.js @@ -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;