pl-fe: trim www. on link domain check

Signed-off-by: Nicole Mikołajczyk <git@mkljczk.pl>
This commit is contained in:
Nicole Mikołajczyk
2025-04-13 22:17:48 +02:00
parent 47945f4d12
commit 7b8439e82d

View File

@ -25,10 +25,11 @@ const nodesToText = (nodes: Array<DOMNode>): string =>
const isHostNotVisible = (href: string, nodes: Array<DOMNode>): false | string => {
try {
const { host } = new URL(href);
let { host } = new URL(href);
host = host.replace(/^www\./, '');
const text = nodesToText(nodes).trim();
if (new RegExp(`^(https?://)?(www\.)?${host}(/|$)`).test(text)) {
if (new RegExp(`^(https?://)?(www.)?${host}(/|$)`).test(text)) {
return false;
} else {
return host;