Handle invalid URLs in the shouldHideUrl check

This commit is contained in:
Jackson Harper 2022-11-25 16:17:32 +08:00
parent 42a4f22c4b
commit 9fde7c98a4

View file

@ -5,10 +5,14 @@ import { HighlightItemCard } from './HighlightItemCard'
import { PageType } from '../../../lib/networking/fragments/articleFragment'
const shouldHideUrl = (url: string): boolean => {
const origin = new URL(url).origin
const hideHosts = ['https://storage.googleapis.com', 'https://omnivore.app']
if (hideHosts.indexOf(origin) != -1) {
return true
try {
const origin = new URL(url).origin
const hideHosts = ['https://storage.googleapis.com', 'https://omnivore.app']
if (hideHosts.indexOf(origin) != -1) {
return true
}
} catch {
console.log('invalid url item', url)
}
return false
}