diff options
Diffstat (limited to 'src')
| -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, |