Exclude domains from link previews
This commit is contained in:
parent
d42aec4dac
commit
ff4ea76005
2 changed files with 44 additions and 10 deletions
|
@ -48,11 +48,35 @@ export function shouldPreviewHref(href: string): boolean {
|
|||
return Boolean(
|
||||
url &&
|
||||
url.protocol === 'https:' &&
|
||||
url.hostname !== 'debuglogs.org' &&
|
||||
!isDomainExcluded(url) &&
|
||||
!isLinkSneaky(href)
|
||||
);
|
||||
}
|
||||
|
||||
const EXCLUDED_DOMAINS = [
|
||||
'debuglogs.org',
|
||||
'example',
|
||||
'example.com',
|
||||
'example.net',
|
||||
'example.org',
|
||||
'invalid',
|
||||
'localhost',
|
||||
'onion',
|
||||
'test',
|
||||
];
|
||||
|
||||
function isDomainExcluded(url: URL): boolean {
|
||||
for (const excludedDomain of EXCLUDED_DOMAINS) {
|
||||
if (
|
||||
url.hostname.endsWith(`.${excludedDomain}`) ||
|
||||
url.hostname === excludedDomain
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
const DIRECTIONAL_OVERRIDES = /[\u202c\u202d\u202e]/;
|
||||
const UNICODE_DRAWING = /[\u2500-\u25FF]/;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue