Skip to content

Commit

Permalink
fix: properly handle mailto links in markdown
Browse files Browse the repository at this point in the history
  • Loading branch information
egoist committed Dec 16, 2018
1 parent 27e80b6 commit c815eec
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/utils/marked.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 + '"'
}
Expand Down

0 comments on commit c815eec

Please sign in to comment.