From 7b8439e82da92a36b7f661fd893b14128ef72841 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicole=20Miko=C5=82ajczyk?= Date: Sun, 13 Apr 2025 22:17:48 +0200 Subject: [PATCH] pl-fe: trim www. on link domain check MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Nicole Mikołajczyk --- packages/pl-fe/src/components/parsed-content.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/pl-fe/src/components/parsed-content.tsx b/packages/pl-fe/src/components/parsed-content.tsx index 970464a48..9ea15dede 100644 --- a/packages/pl-fe/src/components/parsed-content.tsx +++ b/packages/pl-fe/src/components/parsed-content.tsx @@ -25,10 +25,11 @@ const nodesToText = (nodes: Array): string => const isHostNotVisible = (href: string, nodes: Array): 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;