"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var matcher_1 = require("./matcher");
var regex_lib_1 = require("../regex-lib");
var tld_regex_1 = require("./tld-regex");
var email_match_1 = require("../match/email-match");
/**
* @class Autolinker.matcher.Email
* @extends Autolinker.matcher.Matcher
*
* Matcher to find email matches in an input string.
*
* See this class's superclass ({@link Autolinker.matcher.Matcher}) for more details.
*/
var EmailMatcher = (function (_super) {
__extends(EmailMatcher, _super);
function EmailMatcher() {
var _this = _super !== null && _super.apply(this, arguments) || this;
/**
* The regular expression to match email addresses. Example match:
*
* person@place.com
*
* @protected
* @property {RegExp} matcherRegex
*/
_this.matcherRegex = (function () {
var specialCharacters = '!#$%&\'*+\\-\\/=?^_`{|}~', restrictedSpecialCharacters = '\\s"(),:;<>@\\[\\]', validCharacters = regex_lib_1.alphaNumericAndMarksCharsStr + specialCharacters, validRestrictedCharacters = validCharacters + restrictedSpecialCharacters, emailRegex = new RegExp('(?:[' + validCharacters + '](?:[' + validCharacters + ']|\\.(?!\\.|@))*|\\"[' + validRestrictedCharacters + '.]+\\")@');
return new RegExp([
emailRegex.source,
regex_lib_1.getDomainNameStr(1),
'\\.', tld_regex_1.tldRegex.source // '.com', '.net', etc
].join(""), 'gi');
})();
return _this;
}
/**
* @inheritdoc
*/
EmailMatcher.prototype.parseMatches = function (text) {
var matcherRegex = this.matcherRegex, tagBuilder = this.tagBuilder, matches = [], match;
while ((match = matcherRegex.exec(text)) !== null) {
var matchedText = match[0];
matches.push(new email_match_1.EmailMatch({
tagBuilder: tagBuilder,
matchedText: matchedText,
offset: match.index,
email: matchedText
}));
}
return matches;
};
return EmailMatcher;
}(matcher_1.Matcher));
exports.EmailMatcher = EmailMatcher;
//# sourceMappingURL=email-matcher.js.map