Remove www in the hostname if exists

This commit is contained in:
Hongbo Wu 2022-05-12 10:32:35 +08:00
parent b4ec812f41
commit 412d7cebc6

View file

@ -6,10 +6,10 @@ import { PageType } from '../../../lib/networking/fragments/articleFragment'
const siteName = (originalArticleUrl: string, itemUrl: string): string => {
try {
return new URL(originalArticleUrl).hostname
return new URL(originalArticleUrl).hostname.replace(/^www\./, '')
} catch {}
try {
return new URL(itemUrl).hostname
return new URL(itemUrl).hostname.replace(/^www\./, '')
} catch {}
return ''
}