|
|
@ -3,6 +3,7 @@ |
|
|
|
'use strict'; |
|
|
|
|
|
|
|
var url_schemas = require('../common/url_schemas'); |
|
|
|
var normalizeLink = require('../helpers/normalize_link'); |
|
|
|
|
|
|
|
|
|
|
|
/*eslint max-len:0*/ |
|
|
@ -11,7 +12,7 @@ var AUTOLINK_RE = /^<([a-zA-Z.\-]{1,25}):([^<>\x00-\x20]*)>/; |
|
|
|
|
|
|
|
|
|
|
|
module.exports = function autolink(state, silent) { |
|
|
|
var tail, linkMatch, emailMatch, url, pos = state.pos; |
|
|
|
var tail, linkMatch, emailMatch, url, fullUrl, pos = state.pos; |
|
|
|
|
|
|
|
if (state.src.charCodeAt(pos) !== 0x3C/* < */) { return false; } |
|
|
|
|
|
|
@ -25,13 +26,13 @@ module.exports = function autolink(state, silent) { |
|
|
|
if (url_schemas.indexOf(linkMatch[1].toLowerCase()) < 0) { return false; } |
|
|
|
|
|
|
|
url = linkMatch[0].slice(1, -1); |
|
|
|
|
|
|
|
fullUrl = normalizeLink(url); |
|
|
|
if (!state.parser.validateLink(url)) { return false; } |
|
|
|
|
|
|
|
if (!silent) { |
|
|
|
state.push({ |
|
|
|
type: 'link_open', |
|
|
|
href: url, |
|
|
|
href: fullUrl, |
|
|
|
level: state.level |
|
|
|
}); |
|
|
|
state.push({ |
|
|
@ -52,12 +53,13 @@ module.exports = function autolink(state, silent) { |
|
|
|
|
|
|
|
url = emailMatch[0].slice(1, -1); |
|
|
|
|
|
|
|
if (!state.parser.validateLink('mailto:' + url)) { return false; } |
|
|
|
fullUrl = normalizeLink('mailto:' + url); |
|
|
|
if (!state.parser.validateLink(fullUrl)) { return false; } |
|
|
|
|
|
|
|
if (!silent) { |
|
|
|
state.push({ |
|
|
|
type: 'link_open', |
|
|
|
href: 'mailto:' + url, |
|
|
|
href: fullUrl, |
|
|
|
level: state.level |
|
|
|
}); |
|
|
|
state.push({ |
|
|
|