| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
Autolinker.matcher.Email = Autolinker.Util.extend( Autolinker.matcher.Matcher, { |
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
matcherRegex : (function() { |
| 21 |
var alphaNumericChars = Autolinker.RegexLib.alphaNumericCharsStr, |
| 22 |
specialCharacters = '!#$%&\'*+\\-\\/=?^_`{|}~', |
| 23 |
restrictedSpecialCharacters = '\\s"(),:;<>@\\[\\]', |
| 24 |
validCharacters = alphaNumericChars + specialCharacters, |
| 25 |
validRestrictedCharacters = validCharacters + restrictedSpecialCharacters, |
| 26 |
emailRegex = new RegExp( '(?:[' + validCharacters + '](?:[' + validCharacters + ']|\\.(?!\\.|@))*|\\"[' + validRestrictedCharacters + '.]+\\")@'), |
| 27 |
getDomainNameStr = Autolinker.RegexLib.getDomainNameStr, |
| 28 |
tldRegex = Autolinker.tldRegex; |
| 29 |
|
| 30 |
return new RegExp( [ |
| 31 |
emailRegex.source, |
| 32 |
getDomainNameStr(1), |
| 33 |
'\\.', tldRegex.source |
| 34 |
].join( "" ), 'gi' ); |
| 35 |
} )(), |
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
parseMatches : function( text ) { |
| 42 |
var matcherRegex = this.matcherRegex, |
| 43 |
tagBuilder = this.tagBuilder, |
| 44 |
matches = [], |
| 45 |
match; |
| 46 |
|
| 47 |
while( ( match = matcherRegex.exec( text ) ) !== null ) { |
| 48 |
var matchedText = match[ 0 ]; |
| 49 |
|
| 50 |
matches.push( new Autolinker.match.Email( { |
| 51 |
tagBuilder : tagBuilder, |
| 52 |
matchedText : matchedText, |
| 53 |
offset : match.index, |
| 54 |
email : matchedText |
| 55 |
} ) ); |
| 56 |
} |
| 57 |
|
| 58 |
return matches; |
| 59 |
} |
| 60 |
|
| 61 |
} ); |