meta links validation improved

This commit is contained in:
nklhrstv 2020-03-29 22:44:41 +03:00
parent f1e67de5f9
commit 1f3a39a52b

View file

@ -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)}`
});
}
}