Skip to content

Commit 5ed3edf

Browse files
committed
re-use domain+TLD regexes for email matching
1 parent 5348ee5 commit 5ed3edf

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/matcherRegexSource.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ Autolinker.matcherRegex = (function() {
2222
var twitterRegex = /(^|\s)@(\w{1,15})/, // For matching a twitter handle. Ex: @gregory_jacobs
2323

2424
emailRegex = /(?:[\-;:&=\+\$,\w]+@)/, // something@ for email addresses
25-
domainNameWithDot = /[A-Za-z0-9\.\-]+\.[A-Za-z0-9\.\-]+/, // a regex to check for a domain name with at least one '.' in it, for the section after the '@' sign of an email address (so we don't just link any old "hi@you" kind of text)
2625

2726
protocolRegex = /(?:[A-Za-z]{3,9}:(?:\/\/)?)/, // match protocol, allow in format http:// or mailto:
2827
wwwRegex = /(?:www\.)/, // starting with 'www.'
@@ -45,7 +44,8 @@ Autolinker.matcherRegex = (function() {
4544

4645
'(', // *** Capturing group $4, which is used to determine an email match
4746
emailRegex.source,
48-
domainNameWithDot.source,
47+
domainNameRegex.source,
48+
tldRegex.source,
4949
')',
5050

5151
'|',

0 commit comments

Comments
 (0)