diff options
| author | (quasar) nebula <qznebula@protonmail.com> | 2026-01-11 06:19:00 -0400 |
|---|---|---|
| committer | (quasar) nebula <qznebula@protonmail.com> | 2026-01-11 06:19:00 -0400 |
| commit | 062d4e6b4089a4cd0254e805e92aeb7b719683d5 (patch) | |
| tree | 38c5043a7840e12c74d02dcac4851524faec88de | |
| parent | c7916fd1c6206e666655c24595c9610f577e2071 (diff) | |
replacer: yeet / at the end when there's basically only a hostname
| -rw-r--r-- | src/replacer.js | 9 |
1 files changed, 8 insertions, 1 deletions
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, |