From 889a49e0ef477c19de3821f3a6092af9ab9dfaac Mon Sep 17 00:00:00 2001 From: OFF0 Date: Wed, 16 Aug 2023 13:55:39 +0200 Subject: [PATCH] links: remove trailing slash in link text due to URL formatting, the link text of https://example.com was showing as example.com/ removed trailing slash if possible. --- src/utils/dom.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/utils/dom.ts b/src/utils/dom.ts index b408618..4b14bfe 100644 --- a/src/utils/dom.ts +++ b/src/utils/dom.ts @@ -117,11 +117,12 @@ export const parseTextContent = ( return word; } firstLink = firstLink || url.href; + const prettierWithoutSlash = url.pathname === '/'; return elem('a', { href: url.href, target: '_blank', rel: 'noopener noreferrer' - }, url.href.slice(url.protocol.length + 2)); + }, url.href.slice(url.protocol.length + 2, prettierWithoutSlash ? -1 : undefined)); } catch (err) { return word; }