From c815eec61e8ae4655ab71c3a2f507f61c9a74a4f Mon Sep 17 00:00:00 2001 From: EGOIST <0x142857@gmail.com> Date: Mon, 17 Dec 2018 00:05:41 +0800 Subject: [PATCH] fix: properly handle mailto links in markdown --- src/utils/marked.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/utils/marked.js b/src/utils/marked.js index 3876de6d..3b33731f 100644 --- a/src/utils/marked.js +++ b/src/utils/marked.js @@ -1107,9 +1107,10 @@ Renderer.prototype.link = function(href, title, text) { return text } var isExternal = /^https?:\/\//.test(href) - var tag = isExternal ? 'a' : 'router-link' + var isMailto = /^mailto:/.test(href) + var tag = (isExternal || isMailto) ? 'a' : 'router-link' var hrefAttr = tag === 'a' ? 'href' : 'to' - var out = `<${tag} ${hrefAttr}="` + escape(isExternal ? href : removeMarkdownExtension(href)) + '"' + var out = `<${tag} ${hrefAttr}="` + escape(isExternal ? href : removeMarkdownExtension(unescape(href))) + '"' if (title) { out += ' title="' + title + '"' }