mirror of
https://github.com/9001/copyparty.git
synced 2025-12-27 10:15:16 -05:00
md: rewrite links to open in viewer; closes #972
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user