File tree Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change 137137 * This also includes a path, url parameters, or hash anchors. Ex: google.com/path/to/file?q1=1&q2=2#myAnchor
138138 */
139139 matcherRegex : ( function ( ) {
140- var twitterRegex = / ( ^ | \s ) @ ( \w { 1 , 15 } ) / , // For matching a twitter handle. Ex: @gregory_jacobs
140+ var twitterRegex = / ( ^ | [ ^ \w ] ) @ ( \w { 1 , 15 } ) / , // For matching a twitter handle. Ex: @gregory_jacobs
141141
142142 emailRegex = / (?: [ \- ; : & = \+ \$ , \w \. ] + @ ) / , // something@ for email addresses (a.k.a. local-part)
143143
Original file line number Diff line number Diff line change @@ -486,6 +486,24 @@ describe( "Autolinker", function() {
486486 } ) ;
487487
488488
489+ it ( "should automatically link twitter handles surrounded by parentheses" , function ( ) {
490+ var result = Autolinker . link ( "Joe's twitter is (@joe_the_man12)" ) ;
491+ expect ( result ) . toBe ( 'Joe\'s twitter is (<a href="https://twitter.com/joe_the_man12" target="_blank">@joe_the_man12</a>)' ) ;
492+ } ) ;
493+
494+
495+ it ( "should automatically link twitter handles surrounded by braces" , function ( ) {
496+ var result = Autolinker . link ( "Joe's twitter is {@joe_the_man12}" ) ;
497+ expect ( result ) . toBe ( 'Joe\'s twitter is {<a href="https://twitter.com/joe_the_man12" target="_blank">@joe_the_man12</a>}' ) ;
498+ } ) ;
499+
500+
501+ it ( "should automatically link twitter handles surrounded by brackets" , function ( ) {
502+ var result = Autolinker . link ( "Joe's twitter is [@joe_the_man12]" ) ;
503+ expect ( result ) . toBe ( 'Joe\'s twitter is [<a href="https://twitter.com/joe_the_man12" target="_blank">@joe_the_man12</a>]' ) ;
504+ } ) ;
505+
506+
489507 it ( "should automatically link multiple twitter handles in a string" , function ( ) {
490508 var result = Autolinker . link ( "@greg is tweeting @joe with @josh" ) ;
491509 expect ( result ) . toBe ( '<a href="https://twitter.com/greg" target="_blank">@greg</a> is tweeting <a href="https://twitter.com/joe" target="_blank">@joe</a> with <a href="https://twitter.com/josh" target="_blank">@josh</a>' ) ;
You can’t perform that action at this time.
0 commit comments