From 1f3a39a52bc0d81d3fd048a5b7666494a9f49709 Mon Sep 17 00:00:00 2001 From: nklhrstv Date: Sun, 29 Mar 2020 22:44:41 +0300 Subject: [PATCH] meta links validation improved --- src/common/MetaPreview/MetaPreview.js | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/src/common/MetaPreview/MetaPreview.js b/src/common/MetaPreview/MetaPreview.js index 2b2d5851b..4419d232b 100644 --- a/src/common/MetaPreview/MetaPreview.js +++ b/src/common/MetaPreview/MetaPreview.js @@ -27,16 +27,12 @@ const MetaPreview = ({ className, compact, name, logo, background, runtime, rele const linksGroups = React.useMemo(() => { return Array.isArray(links) ? links - .filter((link) => { - return link && - typeof link.category === 'string' && - typeof link.url === 'string'; - }) + .filter((link) => link && typeof link.category === 'string' && typeof link.url === 'string') .reduce((linksGroups, { category, name, url }) => { if (category === IMDB_LINK_CATEGORY) { linksGroups[category] = { label: name, - href: `https://www.stremio.com/warning#${encodeURIComponent(`https://www.imdb.com/title/${url}`)}` + href: `https://www.stremio.com/warning#${encodeURIComponent(`https://www.imdb.com/title/${encodeURIComponent(url)}`)}` }; } else if (category === SHARE_LINK_CATEGORY) { linksGroups[category] = { @@ -53,14 +49,12 @@ const MetaPreview = ({ className, compact, name, logo, background, runtime, rele href: `#${path}` }); } - } else { - if (typeof host === 'string' && host.length > 0) { - linksGroups[category] = linksGroups[category] || []; - linksGroups[category].push({ - label: name, - href: `https://www.stremio.com/warning#${encodeURIComponent(url)}` - }); - } + } else if (typeof host === 'string' && host.length > 0) { + linksGroups[category] = linksGroups[category] || []; + linksGroups[category].push({ + label: name, + href: `https://www.stremio.com/warning#${encodeURIComponent(url)}` + }); } }