From 4cbe6f6cdeabd673ed2a1ec5814c764a2ae50532 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; }