Skip to content

Commit 5b1f9c6

Browse files
committed
Merge branch 'mattermost-underscore'
2 parents a961a0b + e366990 commit 5b1f9c6

File tree

5 files changed

+17
-3
lines changed

5 files changed

+17
-3
lines changed

dist/Autolinker.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2867,7 +2867,7 @@ Autolinker.matcher.Email = Autolinker.Util.extend( Autolinker.matcher.Matcher, {
28672867
*/
28682868
matcherRegex : (function() {
28692869
var alphaNumericChars = Autolinker.RegexLib.alphaNumericCharsStr,
2870-
emailRegex = new RegExp( '[' + alphaNumericChars + '\\-;:&=+$.,]+@' ), // something@ for email addresses (a.k.a. local-part)
2870+
emailRegex = new RegExp( '[' + alphaNumericChars + '\\-\\_;:&=+$.,]+@' ), // something@ for email addresses (a.k.a. local-part)
28712871
domainNameRegex = Autolinker.RegexLib.domainNameRegex,
28722872
tldRegex = Autolinker.RegexLib.tldRegex; // match our known top level domains (TLDs)
28732873

dist/Autolinker.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/matcher/Email.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Autolinker.matcher.Email = Autolinker.Util.extend( Autolinker.matcher.Matcher, {
1919
*/
2020
matcherRegex : (function() {
2121
var alphaNumericChars = Autolinker.RegexLib.alphaNumericCharsStr,
22-
emailRegex = new RegExp( '[' + alphaNumericChars + '\\-;:&=+$.,]+@' ), // something@ for email addresses (a.k.a. local-part)
22+
emailRegex = new RegExp( '[' + alphaNumericChars + '\\-\\_;:&=+$.,]+@' ), // something@ for email addresses (a.k.a. local-part)
2323
domainNameRegex = Autolinker.RegexLib.domainNameRegex,
2424
tldRegex = Autolinker.RegexLib.tldRegex; // match our known top level domains (TLDs)
2525

tests/AutolinkerSpec.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -835,6 +835,12 @@ describe( "Autolinker", function() {
835835
} );
836836

837837

838+
it( "should properly link an email address with underscopres", function() {
839+
var result = autolinker.link( "Joe's email is ([email protected])" );
840+
expect( result ).toBe( 'Joe\'s email is (<a href="mailto:[email protected]">[email protected]</a>)' );
841+
} );
842+
843+
838844
it( "should automatically link an email address with accented characters", function() {
839845
var result = autolinker.link( "Joe's email is mañana@mañana.com" );
840846
expect( result ).toBe( 'Joe\'s email is <a href="mailto:mañana@mañana.com">mañana@mañana.com</a>' );

tests/matcher/EmailSpec.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,14 @@ describe( "Autolinker.matcher.Email", function() {
6060
MatchChecker.expectEmailMatch( matches[ 0 ], '[email protected]', 7 );
6161
} );
6262

63+
64+
it( 'a match with underscores should be parsed correctly', function() {
65+
var matches = matcher.parseMatches( 'Hello [email protected]' );
66+
67+
expect( matches.length ).toBe( 1 );
68+
MatchChecker.expectEmailMatch( matches[ 0 ], '[email protected]', 6 );
69+
} );
70+
6371
} );
6472

6573

0 commit comments

Comments
 (0)