From 062d4e6b4089a4cd0254e805e92aeb7b719683d5 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Sun, 11 Jan 2026 06:19:00 -0400 Subject: replacer: yeet / at the end when there's basically only a hostname --- src/replacer.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/replacer.js b/src/replacer.js index 8a929444..9be14755 100644 --- a/src/replacer.js +++ b/src/replacer.js @@ -934,7 +934,7 @@ export function postprocessExternalLinks(inputNodes) { let parseFrom = 0; for (const match of matchInlineLinks(node.data)) { - const {href, index, length} = match; + let {href, index, length} = match; textNode.data += node.data.slice(parseFrom, index); @@ -950,6 +950,13 @@ export function postprocessExternalLinks(inputNodes) { }; } + try { + const url = new URL(href); + if (url.pathname === '/' && !url.search && !url.hash) { + href = href.replace(/\/$/, ''); + } + } catch {} + outputNodes.push({ i: node.i + index, iEnd: node.i + index + length, -- cgit 1.3.0-6-gf8a5