@@ -96,9 +96,29 @@ describe( "Autolinker", function() {
96
96
} ) ;
97
97
98
98
99
- it ( "should not include the '?' char if it is at the end of the URL" , function ( ) {
100
- var result = autolinker . link ( "Joe went to http://localhost:8000? today" ) ;
101
- expect ( result ) . toBe ( 'Joe went to <a href="http://localhost:8000">localhost:8000</a>? today' ) ;
99
+ it ( "should not include [?!:,.;] chars if at the end of the URL" , function ( ) {
100
+ var result1 = autolinker . link ( "Joe went to http://localhost:8000? today" ) ;
101
+ expect ( result1 ) . toBe ( 'Joe went to <a href="http://localhost:8000">localhost:8000</a>? today' ) ;
102
+ var result2 = autolinker . link ( "Joe went to http://localhost:8000! today" ) ;
103
+ expect ( result2 ) . toBe ( 'Joe went to <a href="http://localhost:8000">localhost:8000</a>! today' ) ;
104
+ var result3 = autolinker . link ( "Joe went to http://localhost:8000: today" ) ;
105
+ expect ( result3 ) . toBe ( 'Joe went to <a href="http://localhost:8000">localhost:8000</a>: today' ) ;
106
+ var result4 = autolinker . link ( "Joe went to http://localhost:8000, today" ) ;
107
+ expect ( result4 ) . toBe ( 'Joe went to <a href="http://localhost:8000">localhost:8000</a>, today' ) ;
108
+ var result5 = autolinker . link ( "Joe went to http://localhost:8000. today" ) ;
109
+ expect ( result5 ) . toBe ( 'Joe went to <a href="http://localhost:8000">localhost:8000</a>. today' ) ;
110
+ var result6 = autolinker . link ( "Joe went to http://localhost:8000; today" ) ;
111
+ expect ( result6 ) . toBe ( 'Joe went to <a href="http://localhost:8000">localhost:8000</a>; today' ) ;
112
+ } ) ;
113
+
114
+
115
+ it ( "should exclude invalid chars after TLD" , function ( ) {
116
+ var result1 = autolinker . link ( "Joe went to http://www.yahoo.com's today" ) ;
117
+ expect ( result1 ) . toBe ( 'Joe went to <a href="http://www.yahoo.com">yahoo.com</a>\'s today' ) ;
118
+ var result2 = autolinker . link ( "Joe went to https://www.yahoo.com/foo's today" ) ;
119
+ expect ( result2 ) . toBe ( 'Joe went to <a href="https://www.yahoo.com/foo\'s">yahoo.com/foo\'s</a> today' ) ;
120
+ var result3 = autolinker . link ( "Joe went to http://www.yahoo.com's/foo today" ) ;
121
+ expect ( result3 ) . toBe ( 'Joe went to <a href="http://www.yahoo.com">yahoo.com</a>\'s/foo today' ) ;
102
122
} ) ;
103
123
104
124
@@ -374,9 +394,29 @@ describe( "Autolinker", function() {
374
394
} ) ;
375
395
376
396
377
- it ( "should not include the '?' char if it is at the end of the URL" , function ( ) {
378
- var result = autolinker . link ( "Joe went to www.yahoo.com? today" ) ;
379
- expect ( result ) . toBe ( 'Joe went to <a href="http://www.yahoo.com">yahoo.com</a>? today' ) ;
397
+ it ( "should not include [?!:,.;] chars if at the end of the URL" , function ( ) {
398
+ var result1 = autolinker . link ( "Joe went to www.yahoo.com? today" ) ;
399
+ expect ( result1 ) . toBe ( 'Joe went to <a href="http://www.yahoo.com">yahoo.com</a>? today' ) ;
400
+ var result2 = autolinker . link ( "Joe went to www.yahoo.com! today" ) ;
401
+ expect ( result2 ) . toBe ( 'Joe went to <a href="http://www.yahoo.com">yahoo.com</a>! today' ) ;
402
+ var result3 = autolinker . link ( "Joe went to www.yahoo.com: today" ) ;
403
+ expect ( result3 ) . toBe ( 'Joe went to <a href="http://www.yahoo.com">yahoo.com</a>: today' ) ;
404
+ var result4 = autolinker . link ( "Joe went to www.yahoo.com, today" ) ;
405
+ expect ( result4 ) . toBe ( 'Joe went to <a href="http://www.yahoo.com">yahoo.com</a>, today' ) ;
406
+ var result5 = autolinker . link ( "Joe went to www.yahoo.com. today" ) ;
407
+ expect ( result5 ) . toBe ( 'Joe went to <a href="http://www.yahoo.com">yahoo.com</a>. today' ) ;
408
+ var result6 = autolinker . link ( "Joe went to www.yahoo.com; today" ) ;
409
+ expect ( result6 ) . toBe ( 'Joe went to <a href="http://www.yahoo.com">yahoo.com</a>; today' ) ;
410
+ } ) ;
411
+
412
+
413
+ it ( "should exclude invalid chars after TLD" , function ( ) {
414
+ var result1 = autolinker . link ( "Joe went to www.yahoo.com's today" ) ;
415
+ expect ( result1 ) . toBe ( 'Joe went to <a href="http://www.yahoo.com">yahoo.com</a>\'s today' ) ;
416
+ var result2 = autolinker . link ( "Joe went to www.yahoo.com/foo's today" ) ;
417
+ expect ( result2 ) . toBe ( 'Joe went to <a href="http://www.yahoo.com/foo\'s">yahoo.com/foo\'s</a> today' ) ;
418
+ var result3 = autolinker . link ( "Joe went to www.yahoo.com's/foo today" ) ;
419
+ expect ( result3 ) . toBe ( 'Joe went to <a href="http://www.yahoo.com">yahoo.com</a>\'s/foo today' ) ;
380
420
} ) ;
381
421
382
422
} ) ;
@@ -444,9 +484,28 @@ describe( "Autolinker", function() {
444
484
} ) ;
445
485
446
486
447
- it ( "should not include the '?' char if it is at the end of the URL" , function ( ) {
448
- var result = autolinker . link ( "Joe went to yahoo.com? today" ) ;
449
- expect ( result ) . toBe ( 'Joe went to <a href="http://yahoo.com">yahoo.com</a>? today' ) ;
487
+ it ( "should not include [?!:,.;] chars if at the end of the URL" , function ( ) {
488
+ var result1 = autolinker . link ( "Joe went to yahoo.com? today" ) ;
489
+ expect ( result1 ) . toBe ( 'Joe went to <a href="http://yahoo.com">yahoo.com</a>? today' ) ;
490
+ var result2 = autolinker . link ( "Joe went to yahoo.com! today" ) ;
491
+ expect ( result2 ) . toBe ( 'Joe went to <a href="http://yahoo.com">yahoo.com</a>! today' ) ;
492
+ var result3 = autolinker . link ( "Joe went to yahoo.com: today" ) ;
493
+ expect ( result3 ) . toBe ( 'Joe went to <a href="http://yahoo.com">yahoo.com</a>: today' ) ;
494
+ var result4 = autolinker . link ( "Joe went to yahoo.com, today" ) ;
495
+ expect ( result4 ) . toBe ( 'Joe went to <a href="http://yahoo.com">yahoo.com</a>, today' ) ;
496
+ var result5 = autolinker . link ( "Joe went to yahoo.com. today" ) ;
497
+ expect ( result5 ) . toBe ( 'Joe went to <a href="http://yahoo.com">yahoo.com</a>. today' ) ;
498
+ var result6 = autolinker . link ( "Joe went to yahoo.com; today" ) ;
499
+ expect ( result6 ) . toBe ( 'Joe went to <a href="http://yahoo.com">yahoo.com</a>; today' ) ;
500
+ } ) ;
501
+
502
+ it ( "should exclude invalid chars after TLD" , function ( ) {
503
+ var result1 = autolinker . link ( "Joe went to yahoo.com's today" ) ;
504
+ expect ( result1 ) . toBe ( 'Joe went to <a href="http://yahoo.com">yahoo.com</a>\'s today' ) ;
505
+ var result2 = autolinker . link ( "Joe went to yahoo.com/foo's today" ) ;
506
+ expect ( result2 ) . toBe ( 'Joe went to <a href="http://yahoo.com/foo\'s">yahoo.com/foo\'s</a> today' ) ;
507
+ var result3 = autolinker . link ( "Joe went to yahoo.com's/foo today" ) ;
508
+ expect ( result3 ) . toBe ( 'Joe went to <a href="http://yahoo.com">yahoo.com</a>\'s/foo today' ) ;
450
509
} ) ;
451
510
452
511
} ) ;
0 commit comments