From 278a0d8548548f066da40230a0473a887026847e Mon Sep 17 00:00:00 2001 From: ed Date: Mon, 1 Dec 2025 17:23:47 +0000 Subject: [PATCH] md: rewrite links to open in viewer; closes #972 --- copyparty/web/md.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/copyparty/web/md.js b/copyparty/web/md.js index 66be69bb..7889f4f3 100644 --- a/copyparty/web/md.js +++ b/copyparty/web/md.js @@ -239,6 +239,12 @@ function convert_markdown(md_text, dest_dom) { var href = nodes[a].getAttribute('href'); var txt = nodes[a].innerHTML; + if (/\.[Mm][Dd]$/.test(href)) { + var o = new URL(href, location.href).origin; + if (!o || o == location.origin) + nodes[a].href = href + '?v'; + } + if (!txt) nodes[a].textContent = href; else if (href !== txt && !nodes[a].className)