diff --git a/lib/markdown.ts b/lib/markdown.ts index 0a9558a..9599e09 100644 --- a/lib/markdown.ts +++ b/lib/markdown.ts @@ -58,14 +58,14 @@ md.renderer.rules.link_open = function(tokens, index, options, env, self) { if (href != null) { try { const parsed = new URL(href); - const formattedPathname = parsed.pathname === "/" ? "" : parsed.pathname;//.length > 20 ? parsed.pathname.substr(0, 20) + "..." : parsed.pathname; + const formattedPathname = parsed.pathname === "/" ? "" : parsed.pathname; let formatted = `${parsed.hostname}${formattedPathname}`; if (formatted.length > 40) { formatted = formatted.substr(0, 40) + "..."; } tokens[index].attrPush(["data-link", formatted]); } catch (e) { - // URL constructor throws on invalid URLs (such as ones that only contain a fragment), so swallow those exceptions + tokens[index].attrPush(["data-link", href]); } }