-
Notifications
You must be signed in to change notification settings - Fork 239
/
autolinker-url.spec.ts
1222 lines (1050 loc) · 64.6 KB
/
autolinker-url.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import _ from 'lodash';
import Autolinker from '../src/autolinker';
import { generateLinkTests } from './util/generate-link-tests';
describe('Autolinker Url Matching >', () => {
const autolinker = new Autolinker({
newWindow: false,
stripPrefix: {
www: false, // for the purposes of the generated tests, leaving this as false makes it easier to automatically create the 'expected' values
},
}); // so that target="_blank" is not added to resulting autolinked URLs
describe(`scheme-prefixed URLs (i.e. URLs starting with 'http://' or 'somescheme:') >`, () => {
describe('combination URL tests >', () => {
generateCombinationTests({
schemes: ['http://', 'https://' /*, 'mailto:'*/],
hosts: [
'yahoo.com',
'subdomain1.subdomain2.yahoo.com',
'subdomain_with_underscores.yahoo.com',
'subdomain-with-dashes.some-domain.com',
'localhost',
'66.102.7.147',
],
ports: ['', ':8080'],
});
});
it('should link scheme URLs that are only numbers', () => {
let result = autolinker.link('Joe went to bugtracker://20012909');
expect(result).toBe(
'Joe went to <a href="bugtracker://20012909">bugtracker://20012909</a>'
);
});
it('should automatically link capitalized URLs', () => {
let result1 = autolinker.link('Joe went to HTTP://YAHOO.COM');
expect(result1).toBe('Joe went to <a href="HTTP://YAHOO.COM">YAHOO.COM</a>');
let result2 = autolinker.link('Joe went to HTTP://WWW.YAHOO.COM');
expect(result2).toBe('Joe went to <a href="HTTP://WWW.YAHOO.COM">WWW.YAHOO.COM</a>');
});
it('should automatically link URLs with periods in the path', () => {
const result1 = autolinker.link(
'https://images-na.ssl-images-amazon.com/images/I/912ozjp0ytL._SY450_.jpg'
);
expect(result1).toBe(
'<a href="https://images-na.ssl-images-amazon.com/images/I/912ozjp0ytL._SY450_.jpg">images-na.ssl-images-amazon.com/images/I/912ozjp0ytL._SY450_.jpg</a>'
);
const result2 = autolinker.link(
'My image is at: https://images-na.ssl-images-amazon.com/images/I/912ozjp0ytL._SY450_.jpg - check it out'
);
expect(result2).toBe(
'My image is at: <a href="https://images-na.ssl-images-amazon.com/images/I/912ozjp0ytL._SY450_.jpg">images-na.ssl-images-amazon.com/images/I/912ozjp0ytL._SY450_.jpg</a> - check it out'
);
});
it('should automatically link a URL with accented characters', () => {
let result = autolinker.link(
'Joe went to http://mañana.com/mañana?mañana=1#mañana today.'
);
expect(result).toBe(
'Joe went to <a href="http://mañana.com/mañana?mañana=1#mañana">mañana.com/mañana?mañana=1#mañana</a> today.'
);
});
it('should automatically link cyrillic URLs', () => {
let result = autolinker.link(
'Joe went to https://ru.wikipedia.org/wiki/Кириллица?Кириллица=1#Кириллица'
);
expect(result).toBe(
'Joe went to <a href="https://ru.wikipedia.org/wiki/Кириллица?Кириллица=1#Кириллица">ru.wikipedia.org/wiki/Кириллица?Кириллица=1#Кириллица</a>'
);
});
it('should match local urls with numbers when prefixed with http://', () => {
let result1 = autolinker.link('http://localhost.local001/test');
expect(result1).toBe(
'<a href="http://localhost.local001/test">localhost.local001/test</a>'
);
let result2 = autolinker.link('http://suus111.w10:8090/display/test/AI');
expect(result2).toBe(
'<a href="http://suus111.w10:8090/display/test/AI">suus111.w10:8090/display/test/AI</a>'
);
});
it('should match a url with underscores in domain label', () => {
let result = autolinker.link('https://gcs_test_env.storage.googleapis.com/file.pdf');
expect(result).toBe(
'<a href="https://gcs_test_env.storage.googleapis.com/file.pdf">gcs_test_env.storage.googleapis.com/file.pdf</a>'
);
});
it('should not match an address with multiple dots', () => {
expect(autolinker.link('hello:...world')).toBe('hello:...world');
expect(autolinker.link('hello:wo.....rld')).toBe('hello:wo.....rld');
});
it("should NOT include preceding ':' introductions without a space", () => {
let result1 = autolinker.link('the link:http://example.com/');
expect(result1).toBe('the link:<a href="http://example.com/">example.com</a>');
let result2 = autolinker.link('the link:git:example.com/');
expect(result2).toBe('the link:<a href="git:example.com/">git:example.com</a>');
});
it('should autolink protocols with at least one character', () => {
let result = autolinker.link('link this: g://example.com/');
expect(result).toBe('link this: <a href="g://example.com/">g://example.com</a>');
});
it('should autolink protocols with more than 9 characters (as was the previous upper bound, but it seems protocols may be longer)', () => {
let result = autolinker.link('link this: opaquelocktoken://example');
expect(result).toBe(
'link this: <a href="opaquelocktoken://example">opaquelocktoken://example</a>'
);
});
it('should autolink protocols with digits, dashes, dots, and plus signs in their names', () => {
let result1 = autolinker.link('link this: a1://example');
expect(result1).toBe('link this: <a href="a1://example">a1://example</a>');
let result2 = autolinker.link('link this: view-source://example');
expect(result2).toBe(
'link this: <a href="view-source://example">view-source://example</a>'
);
let result3 = autolinker.link('link this: iris.xpc://example');
expect(result3).toBe('link this: <a href="iris.xpc://example">iris.xpc://example</a>');
let result4 = autolinker.link('link this: test+protocol://example');
expect(result4).toBe(
'link this: <a href="test+protocol://example">test+protocol://example</a>'
);
// Test all allowed non-alpha chars
let result5 = autolinker.link('link this: test+proto-col.123://example');
expect(result5).toBe(
'link this: <a href="test+proto-col.123://example">test+proto-col.123://example</a>'
);
});
it('should NOT autolink protocols that start with a digit, dash, plus sign, or dot, as per http://tools.ietf.org/html/rfc3986#section-3.1', () => {
let result1 = autolinker.link('do not link first char: -a://example');
expect(result1).toBe('do not link first char: -<a href="a://example">a://example</a>');
let result2 = autolinker.link('do not link first char: +a://example');
expect(result2).toBe('do not link first char: +<a href="a://example">a://example</a>');
let result3 = autolinker.link('do not link first char: .a://example');
expect(result3).toBe('do not link first char: .<a href="a://example">a://example</a>');
let result4 = autolinker.link('do not link first char: .aa://example');
expect(result4).toBe(
'do not link first char: .<a href="aa://example">aa://example</a>'
);
});
it('should autolink protocol starting at http:// or http:// if URL is preceded with text', () => {
let result1 = autolinker.link('link this: xxxhttp://example.com');
expect(result1).toBe('link this: xxx<a href="http://example.com">example.com</a>');
let result2 = autolinker.link('link this: abchttps://www.example.com');
expect(result2).toBe(
'link this: abc<a href="https://www.example.com">www.example.com</a>'
);
});
it('should link a URL with a check character', () => {
let result = autolinker.link(
'https://gitlab.example.com/search?utf8=✓&search=mysearch&group_id=&project_id=42&search_code=true&repository_ref=master'
);
expect(result).toBe(
'<a href="https://gitlab.example.com/search?utf8=✓&search=mysearch&group_id=&project_id=42&search_code=true&repository_ref=master">gitlab.example.com/search?utf8=✓&search=mysearch&group_id=&project_id=42&search_code=true&repository_ref=master</a>'
);
});
it('should match any local URL with numbers', function () {
const result1 = autolinker.link('http://localhost.local001/test');
expect(result1).toBe(
'<a href="http://localhost.local001/test">localhost.local001/test</a>'
);
const result2 = autolinker.link('http://suus111.w10:8090/display/test/AI');
expect(result2).toBe(
'<a href="http://suus111.w10:8090/display/test/AI">suus111.w10:8090/display/test/AI</a>'
);
});
it('should match katakana with dakuten characters (symbol with combining mark - two unicode characters)', () => {
const result = autolinker.link('https://website.com/files/name-ボ.pdf');
expect(result).toBe(
'<a href="https://website.com/files/name-ボ.pdf">website.com/files/name-ボ.pdf</a>'
);
});
it('should parse long contiguous characters with no spaces in a timely manner', function () {
const str = new Array(10000).join('a');
const start = Date.now();
autolinker.link(str);
expect(Date.now() - start).toBeLessThan(100);
});
it('should match urls containing emoji', function () {
const result = autolinker.link('emoji url http://📙.la/🧛🏻♂️ mid-sentence');
expect(result).toBe(`emoji url <a href="http://📙.la/🧛🏻♂️">📙.la/🧛🏻♂️</a> mid-sentence`);
});
it('should match urls if a URL begins after a colon', function () {
const result = autolinker.link('stuff :https://nia.nexon.com testing');
expect(result).toBe(`stuff :<a href="https://nia.nexon.com">nia.nexon.com</a> testing`);
});
it(`should match urls if a URL begins after a semicolon (i.e. char that isn't part of a url)`, function () {
const result = autolinker.link('Link 1;https://nia.nexon.com testing');
expect(result).toBe(`Link 1;<a href="https://nia.nexon.com">nia.nexon.com</a> testing`);
});
it('should match urls if a URL begins after a numeric character+colon (https://github.com/gregjacobs/Autolinker.js/issues/413)', function () {
const result = autolinker.link('Link 1:https://nia.nexon.com testing');
expect(result).toBe(`Link 1:<a href="https://nia.nexon.com">nia.nexon.com</a> testing`);
});
it('should match urls if a URL begins after a non-latin character+colon', function () {
const result = autolinker.link('한글:https://nia.nexon.com testing');
expect(result).toBe(`한글:<a href="https://nia.nexon.com">nia.nexon.com</a> testing`);
});
it('should match urls if a URL begins after a non-latin character+colon (https://github.com/gregjacobs/Autolinker.js/issues/394)', function () {
const result = autolinker.link('链接:https://www.google.com testing');
expect(result).toBe(`链接:<a href="https://www.google.com">www.google.com</a> testing`);
});
it('should match urls if a URL begins after a non-latin character+colon #2 (https://github.com/gregjacobs/Autolinker.js/issues/394)', function () {
const result = autolinker.link('こちら→https://google.com testing');
expect(result).toBe(`こちら→<a href="https://google.com">google.com</a> testing`);
});
it('should match urls if a URL begins after a Persian character (https://github.com/gregjacobs/Autolinker.js/issues/409)', function () {
const result = autolinker.link('این یک لینک استhttps://www.example.com testing');
expect(result).toBe(
`این یک لینک است<a href="https://www.example.com">www.example.com</a> testing`
);
});
it('should match urls if a URL begins after an equals sign (much like an environment var assignment) (https://github.com/gregjacobs/Autolinker.js/issues/405)', function () {
const result = autolinker.link('FOO=https://example.com');
expect(result).toBe(`FOO=<a href="https://example.com">example.com</a>`);
});
it('should match urls with scheme starting with an emoji', function () {
const result = autolinker.link('emoji url 👉http://📙.la/🧛🏻♂️ mid-sentence');
expect(result).toBe(`emoji url 👉<a href="http://📙.la/🧛🏻♂️">📙.la/🧛🏻♂️</a> mid-sentence`);
});
it("should NOT autolink possible URLs with the 'javascript:' URI scheme", () => {
let result = autolinker.link("do not link javascript:window.alert('hi') please");
expect(result).toBe("do not link javascript:window.alert('hi') please");
});
it("should NOT autolink possible URLs with the 'javascript:' URI scheme, with different upper/lowercase letters in the uri scheme", () => {
let result = autolinker.link("do not link JavAscriPt:window.alert('hi') please");
expect(result).toBe("do not link JavAscriPt:window.alert('hi') please");
});
it("should NOT autolink possible URLs with the 'vbscript:' URI scheme", () => {
let result = autolinker.link("do not link vbscript:window.alert('hi') please");
expect(result).toBe("do not link vbscript:window.alert('hi') please");
});
it("should NOT autolink possible URLs with the 'vbscript:' URI scheme, with different upper/lowercase letters in the uri scheme", () => {
let result = autolinker.link("do not link vBsCriPt:window.alert('hi') please");
expect(result).toBe("do not link vBsCriPt:window.alert('hi') please");
});
it("should NOT automatically link strings of the form 'git:d' (using the heuristic that the domain name does not have a '.' in it)", () => {
let result = autolinker.link('Something like git:d should not be linked as a URL');
expect(result).toBe('Something like git:d should not be linked as a URL');
});
it("should NOT automatically link strings of the form 'git:domain' (using the heuristic that the domain name does not have a '.' in it)", () => {
let result = autolinker.link('Something like git:domain should not be linked as a URL');
expect(result).toBe('Something like git:domain should not be linked as a URL');
});
it("should automatically link strings of the form 'git:domain.com', interpreting this as a protocol and domain name", () => {
let result = autolinker.link('Something like git:domain.com should be linked as a URL');
expect(result).toBe(
'Something like <a href="git:domain.com">git:domain.com</a> should be linked as a URL'
);
});
it("should NOT automatically link a string in the form of 'version:1.0'", () => {
let result = autolinker.link('version:1.0');
expect(result).toBe('version:1.0');
});
it("should NOT automatically link these 'abc:def' style strings", () => {
let strings = [
'BEGIN:VCALENDAR',
'VERSION:1.0',
'BEGIN:VEVENT',
'DTSTART:20140401T090000',
'DTEND:20140401T100000',
'SUMMARY:Some thing to do',
'LOCATION:',
'DESCRIPTION:Just call this guy yeah! Testings',
'PRIORITY:3',
'END:VEVENT',
'END:VCALENDAR',
'START:123',
'START:123:SOMETHING',
];
let i,
len = strings.length,
str;
// Test with just the strings themselves.
for (i = 0; i < len; i++) {
str = strings[i];
expect(autolinker.link(str)).toBe(str); // none should be autolinked
}
// Test with the strings surrounded by other text
for (i = 0; i < len; i++) {
str = strings[i];
expect(autolinker.link('test ' + str + ' test')).toBe('test ' + str + ' test'); // none should be autolinked
}
});
it(`should not autolink schemes with authority chars that don't have a host`, () => {
expect(autolinker.link('http://')).toBe('http://');
expect(autolinker.link('http://.')).toBe('http://.');
expect(autolinker.link('http://#')).toBe('http://#');
expect(autolinker.link('http://##')).toBe('http://##');
expect(autolinker.link('http://?')).toBe('http://?');
expect(autolinker.link('http://??')).toBe('http://??');
});
});
describe(`URLs with no scheme prefix but a known TLD (i.e. 'google.com') >`, () => {
describe('combination URL tests >', () => {
generateCombinationTests({
schemes: [''], // no scheme
hosts: [
'yahoo.com',
'www.yahoo.com', // specifically the 'www' prefix
'WWW.YAHOO.COM', // all caps
'subdomain1.subdomain2.yahoo.com',
'subdomain_with_underscores.yahoo.com',
],
ports: ['', ':8080'],
});
});
it(`should link a basic TLD URL`, () => {
let result1 = autolinker.link('yahoo.com');
expect(result1).toBe('<a href="http://yahoo.com">yahoo.com</a>');
});
it(`should link a basic TLD URL with a port`, () => {
let result1 = autolinker.link('yahoo.com:8080');
expect(result1).toBe('<a href="http://yahoo.com:8080">yahoo.com:8080</a>');
});
it('should automatically link domain names represented in punicode', () => {
let result1 = autolinker.link(
'For compatibility reasons, xn--d1acufc.xn--p1ai is an acceptable form of an international domain.'
);
expect(result1).toBe(
'For compatibility reasons, <a href="http://xn--d1acufc.xn--p1ai">xn--d1acufc.xn--p1ai</a> is an acceptable form of an international domain.'
);
let result2 = autolinker.link(
'For compatibility reasons, http://xn--d1acufc.xn--p1ai is an acceptable form of an international domain.'
);
expect(result2).toBe(
'For compatibility reasons, <a href="http://xn--d1acufc.xn--p1ai">xn--d1acufc.xn--p1ai</a> is an acceptable form of an international domain.'
);
});
it('should automatically link international domain names', () => {
let result1 = autolinker.link('Русским гораздо проще набрать россия.рф на клавиатуре.');
expect(result1).toBe(
'Русским гораздо проще набрать <a href="http://россия.рф">россия.рф</a> на клавиатуре.'
);
let result2 = autolinker.link(
'Русским гораздо проще набрать http://россия.рф на клавиатуре.'
);
expect(result2).toBe(
'Русским гораздо проще набрать <a href="http://россия.рф">россия.рф</a> на клавиатуре.'
);
let result3 = autolinker.link(
'Русским гораздо проще набрать //россия.рф на клавиатуре.'
);
expect(result3).toBe(
'Русским гораздо проще набрать <a href="//россия.рф">россия.рф</a> на клавиатуре.'
);
});
it('should not match local urls with numbers when NOT prefixed with http://', () => {
let result1 = autolinker.link('localhost.local001/test');
expect(result1).toBe('localhost.local001/test');
let result2 = autolinker.link('suus111.w10:8090/display/test/AI');
expect(result2).toBe('suus111.w10:8090/display/test/AI');
});
it("should automatically link 'yahoo.xyz' (a known TLD), but not 'sencha.etc' (an unknown TLD)", () => {
let result = autolinker.link('yahoo.xyz should be linked, sencha.etc should not');
expect(result).toBe(
'<a href="http://yahoo.xyz">yahoo.xyz</a> should be linked, sencha.etc should not'
);
});
it("should automatically link 'a.museum' (a known TLD), but not 'abc.123'", () => {
let result = autolinker.link('a.museum should be linked, but abc.123 should not');
expect(result).toBe(
'<a href="http://a.museum">a.museum</a> should be linked, but abc.123 should not'
);
});
it('should automatically link URLs in the form of yahoo.com, prepending the http:// in this case', () => {
let result = autolinker.link('Joe went to yahoo.com');
expect(result).toBe('Joe went to <a href="http://yahoo.com">yahoo.com</a>');
});
it('should automatically link URLs in the form of subdomain.yahoo.com', () => {
let result = autolinker.link('Joe went to subdomain.yahoo.com');
expect(result).toBe(
'Joe went to <a href="http://subdomain.yahoo.com">subdomain.yahoo.com</a>'
);
});
it('should automatically link URLs in the form of yahoo.co.uk, prepending the http:// in this case', () => {
let result = autolinker.link('Joe went to yahoo.co.uk');
expect(result).toBe('Joe went to <a href="http://yahoo.co.uk">yahoo.co.uk</a>');
});
it('should automatically link URLs in the form of yahoo.ru, prepending the http:// in this case', () => {
let result = autolinker.link('Joe went to yahoo.ru');
expect(result).toBe('Joe went to <a href="http://yahoo.ru">yahoo.ru</a>');
});
it("should automatically link URLs in the form of 'yahoo.com.', without including the trailing period", () => {
let result = autolinker.link('Joe went to yahoo.com.');
expect(result).toBe('Joe went to <a href="http://yahoo.com">yahoo.com</a>.');
});
it("should automatically link URLs in the form of 'yahoo.com:8000' (with a port number)", () => {
let result = autolinker.link('Joe went to yahoo.com:8000 today');
expect(result).toBe(
'Joe went to <a href="http://yahoo.com:8000">yahoo.com:8000</a> today'
);
});
it("should automatically link URLs in the form of 'yahoo.com:8000/abc' (with a port number and path)", () => {
let result = autolinker.link('Joe went to yahoo.com:8000/abc today');
expect(result).toBe(
'Joe went to <a href="http://yahoo.com:8000/abc">yahoo.com:8000/abc</a> today'
);
});
it("should automatically link URLs in the form of 'yahoo.com:8000?abc' (with a port number and query string)", () => {
let result = autolinker.link('Joe went to yahoo.com:8000?abc today');
expect(result).toBe(
'Joe went to <a href="http://yahoo.com:8000?abc">yahoo.com:8000?abc</a> today'
);
});
it("should automatically link URLs in the form of 'yahoo.com:8000#abc' (with a port number and hash)", () => {
let result = autolinker.link('Joe went to yahoo.com:8000#abc today');
expect(result).toBe(
'Joe went to <a href="http://yahoo.com:8000#abc">yahoo.com:8000#abc</a> today'
);
});
it('should automatically link capitalized URLs', () => {
let result = autolinker.link('Joe went to YAHOO.COM.');
expect(result).toBe('Joe went to <a href="http://YAHOO.COM">YAHOO.COM</a>.');
});
it('should not include [?!:,.;] chars if at the end of the URL', () => {
let result1 = autolinker.link('Joe went to yahoo.com? today');
expect(result1).toBe('Joe went to <a href="http://yahoo.com">yahoo.com</a>? today');
let result2 = autolinker.link('Joe went to yahoo.com! today');
expect(result2).toBe('Joe went to <a href="http://yahoo.com">yahoo.com</a>! today');
let result3 = autolinker.link('Joe went to yahoo.com: today');
expect(result3).toBe('Joe went to <a href="http://yahoo.com">yahoo.com</a>: today');
let result4 = autolinker.link('Joe went to yahoo.com, today');
expect(result4).toBe('Joe went to <a href="http://yahoo.com">yahoo.com</a>, today');
let result5 = autolinker.link('Joe went to yahoo.com. today');
expect(result5).toBe('Joe went to <a href="http://yahoo.com">yahoo.com</a>. today');
let result6 = autolinker.link('Joe went to yahoo.com; today');
expect(result6).toBe('Joe went to <a href="http://yahoo.com">yahoo.com</a>; today');
});
it('should exclude invalid chars after TLD', () => {
let result1 = autolinker.link("Joe went to yahoo.com's today");
expect(result1).toBe('Joe went to <a href="http://yahoo.com">yahoo.com</a>\'s today');
let result2 = autolinker.link("Joe went to yahoo.com/foo's today");
expect(result2).toBe(
'Joe went to <a href="http://yahoo.com/foo\'s">yahoo.com/foo\'s</a> today'
);
let result3 = autolinker.link("Joe went to yahoo.com's/foo today");
expect(result3).toBe(
'Joe went to <a href="http://yahoo.com">yahoo.com</a>\'s/foo today'
);
});
it('should match a url with underscores in domain label', () => {
let result = autolinker.link('gcs_test_env.storage.googleapis.com/file.pdf');
expect(result).toBe(
'<a href="http://gcs_test_env.storage.googleapis.com/file.pdf">gcs_test_env.storage.googleapis.com/file.pdf</a>'
);
});
it('should automatically link a URL with accented characters', () => {
let result = autolinker.link('Joe went to mañana.com today.');
expect(result).toBe('Joe went to <a href="http://mañana.com">mañana.com</a> today.');
});
});
describe(`IPv4 addresses without scheme (i.e. '192.168.0.1' without 'http://' prefix) >`, () => {
it(`should match a basic IP address in text >`, () => {
const result = autolinker.link('Joe went to 192.168.0.1 today.');
expect(result).toBe('Joe went to <a href="http://192.168.0.1">192.168.0.1</a> today.');
});
describe('combination URL tests >', () => {
generateCombinationTests({
schemes: [''], // no scheme
hosts: ['4.4.4.4', '192.168.0.1'],
ports: ['', ':8080'],
});
});
it(`should not link an invalid IP with too many octets`, () => {
const text = 'Joe went to 1.2.3.4.5 today';
const result = autolinker.link(text);
expect(result).toBe(text);
});
it(`should not link an invalid IP with too few octets`, () => {
const text = 'Joe went to 1.2.3 today';
const result = autolinker.link(text);
expect(result).toBe(text);
});
it(`should not link an invalid IP that has an octet >255 (400)`, () => {
const text = 'Joe went to 1.2.3.400 today';
const result = autolinker.link(text);
expect(result).toBe(text);
});
it(`should not link an invalid IP that has an octet >255 (1000)`, () => {
const text = 'Joe went to 1000.2.3.4 today';
const result = autolinker.link(text);
expect(result).toBe(text);
});
it(`should not link an invalid IP that has an alpha char in an octet (first octet)`, () => {
const text = 'Joe went to a1.2.3.4 today';
const result = autolinker.link(text);
expect(result).toBe(text);
});
it(`should not link an invalid IP that has a alpha char in an octet, which could be misconstrued with a host name (last octet)`, () => {
const text = 'Joe went to 1.2.3.4a today';
const result = autolinker.link(text);
expect(result).toBe(text);
});
});
describe("protocol-relative URLs (i.e. URLs starting with only '//') >", () => {
describe('combination URL tests >', () => {
generateCombinationTests({
schemes: ['//'],
hosts: [
'yahoo.com',
'subdomain1.subdomain2.yahoo.com',
'subdomain_with_underscores.yahoo.com',
// 'localhost', -- TODO: should this link? Doesn't link in the previous version before state machine implementation (Autolinker 3.x) or linkifyjs, does link in linkify-it
// '66.102.7.147', -- TODO: should this link? Doesn't link in the previous version before state machine implementation (Autolinker 3.x) or linkifyjs, does link in linkify-it
],
ports: ['', ':8080'],
});
});
it('should automatically link protocol-relative URLs in the form of //yahoo.com at the beginning of the string', () => {
let result = autolinker.link('//yahoo.com');
expect(result).toBe('<a href="//yahoo.com">yahoo.com</a>');
});
it('should automatically link protocol-relative URLs in the form of //yahoo.com in the middle of the string', () => {
let result = autolinker.link('Joe went to //yahoo.com yesterday');
expect(result).toBe('Joe went to <a href="//yahoo.com">yahoo.com</a> yesterday');
});
it('should automatically link protocol-relative URLs in the form of //yahoo.com at the end of the string', () => {
let result = autolinker.link('Joe went to //yahoo.com');
expect(result).toBe('Joe went to <a href="//yahoo.com">yahoo.com</a>');
});
it('should automatically link capitalized protocol-relative URLs', () => {
let result = autolinker.link('Joe went to //YAHOO.COM');
expect(result).toBe('Joe went to <a href="//YAHOO.COM">YAHOO.COM</a>');
});
it('should match a url with underscores in domain label', () => {
let result = autolinker.link('//gcs_test_env.storage.googleapis.com/file.pdf');
expect(result).toBe(
'<a href="//gcs_test_env.storage.googleapis.com/file.pdf">gcs_test_env.storage.googleapis.com/file.pdf</a>'
);
});
it('should NOT automatically link supposed protocol-relative URLs in the form of abc//yahoo.com, which is most likely not supposed to be interpreted as a URL', () => {
let result1 = autolinker.link('Joe went to abc//yahoo.com');
expect(result1).toBe('Joe went to abc//yahoo.com');
let result2 = autolinker.link('Относительный протокол//россия.рф');
expect(result2).toBe('Относительный протокол//россия.рф');
});
it('should NOT automatically link supposed protocol-relative URLs in the form of 123//yahoo.com, which is most likely not supposed to be interpreted as a URL', () => {
let result = autolinker.link('Joe went to 123//yahoo.com');
expect(result).toBe('Joe went to 123//yahoo.com');
});
it("should automatically link supposed protocol-relative URLs as long as the character before the '//' is a non-word character", () => {
let result = autolinker.link('Joe went to abc-//yahoo.com');
expect(result).toBe('Joe went to abc-<a href="//yahoo.com">yahoo.com</a>');
});
});
describe('brace handling (parens, square, and curly braces) >', () => {
const testCases = [
{ braceName: 'parenthesis', openBraceChar: '(', closeBraceChar: ')' },
{ braceName: 'square braces', openBraceChar: '[', closeBraceChar: ']' },
{ braceName: 'curly braces', openBraceChar: '{', closeBraceChar: '}' },
];
testCases.forEach(({ braceName, openBraceChar, closeBraceChar }) => {
it(`should include ${braceName} in URLs with paths`, () => {
const result1 = autolinker.link(
`TLDs come from en.wikipedia.org/wiki/IANA_${openBraceChar}disambiguation${closeBraceChar}.`
);
expect(result1).toBe(
`TLDs come from <a href="http://en.wikipedia.org/wiki/IANA_${openBraceChar}disambiguation${closeBraceChar}">en.wikipedia.org/wiki/IANA_${openBraceChar}disambiguation${closeBraceChar}</a>.`
);
const result2 = autolinker.link(
`MSDN has a great article at http://msdn.microsoft.com/en-us/library/aa752574${openBraceChar}VS.85${closeBraceChar}.aspx.`
);
expect(result2).toBe(
`MSDN has a great article at <a href="http://msdn.microsoft.com/en-us/library/aa752574${openBraceChar}VS.85${closeBraceChar}.aspx">msdn.microsoft.com/en-us/library/aa752574${openBraceChar}VS.85${closeBraceChar}.aspx</a>.`
);
});
it(`should include ${braceName} in URLs with query strings`, () => {
const result1 = autolinker.link(
`TLDs come from en.wikipedia.org/wiki?IANA_${openBraceChar}disambiguation${closeBraceChar}.`
);
expect(result1).toBe(
`TLDs come from <a href="http://en.wikipedia.org/wiki?IANA_${openBraceChar}disambiguation${closeBraceChar}">en.wikipedia.org/wiki?IANA_${openBraceChar}disambiguation${closeBraceChar}</a>.`
);
const result2 = autolinker.link(
`MSDN has a great article at http://msdn.microsoft.com/en-us/library?aa752574${openBraceChar}VS.85${closeBraceChar}.aspx.`
);
expect(result2).toBe(
`MSDN has a great article at <a href="http://msdn.microsoft.com/en-us/library?aa752574${openBraceChar}VS.85${closeBraceChar}.aspx">msdn.microsoft.com/en-us/library?aa752574${openBraceChar}VS.85${closeBraceChar}.aspx</a>.`
);
});
it(`should include ${braceName} in URLs with hash anchors`, () => {
const result1 = autolinker.link(
`TLDs come from en.wikipedia.org/wiki#IANA_${openBraceChar}disambiguation${closeBraceChar}.`
);
expect(result1).toBe(
`TLDs come from <a href="http://en.wikipedia.org/wiki#IANA_${openBraceChar}disambiguation${closeBraceChar}">en.wikipedia.org/wiki#IANA_${openBraceChar}disambiguation${closeBraceChar}</a>.`
);
const result2 = autolinker.link(
`MSDN has a great article at http://msdn.microsoft.com/en-us/library#aa752574${openBraceChar}VS.85${closeBraceChar}.aspx.`
);
expect(result2).toBe(
`MSDN has a great article at <a href="http://msdn.microsoft.com/en-us/library#aa752574${openBraceChar}VS.85${closeBraceChar}.aspx">msdn.microsoft.com/en-us/library#aa752574${openBraceChar}VS.85${closeBraceChar}.aspx</a>.`
);
});
it(`when the URL has ${braceName} within it itself, should exclude the final closing brace from the URL when its unmatched`, () => {
const result1 = autolinker.link(
`TLDs come from ${openBraceChar}en.wikipedia.org/wiki/IANA_${openBraceChar}disambiguation${closeBraceChar}${closeBraceChar}.`
);
expect(result1).toBe(
`TLDs come from ${openBraceChar}<a href="http://en.wikipedia.org/wiki/IANA_${openBraceChar}disambiguation${closeBraceChar}">en.wikipedia.org/wiki/IANA_${openBraceChar}disambiguation${closeBraceChar}</a>${closeBraceChar}.`
);
const result2 = autolinker.link(
`MSDN has a great article at ${openBraceChar}http://msdn.microsoft.com/en-us/library/aa752574${openBraceChar}VS.85${closeBraceChar}.aspx${closeBraceChar}.`
);
expect(result2).toBe(
`MSDN has a great article at ${openBraceChar}<a href="http://msdn.microsoft.com/en-us/library/aa752574${openBraceChar}VS.85${closeBraceChar}.aspx">msdn.microsoft.com/en-us/library/aa752574${openBraceChar}VS.85${closeBraceChar}.aspx</a>${closeBraceChar}.`
);
});
it(`should not include final closing ${braceName} in the URL, if it doesn't match opening ${braceName} in the url`, () => {
const result = autolinker.link(
`Click here ${openBraceChar}google.com${closeBraceChar} for more details`
);
expect(result).toBe(
`Click here ${openBraceChar}<a href="http://google.com">google.com</a>${closeBraceChar} for more details`
);
});
it(`should not include final closing ${braceName} in the URL when a path exists`, () => {
const result = autolinker.link(
`Click here ${openBraceChar}google.com/abc${closeBraceChar} for more details`
);
expect(result).toBe(
`Click here ${openBraceChar}<a href="http://google.com/abc">google.com/abc</a>${closeBraceChar} for more details`
);
});
it(`should not include final closing ${braceName} in the URL when a query string exists`, () => {
const result = autolinker.link(
`Click here ${openBraceChar}google.com?abc=1${closeBraceChar} for more details`
);
expect(result).toBe(
`Click here ${openBraceChar}<a href="http://google.com?abc=1">google.com?abc=1</a>${closeBraceChar} for more details`
);
});
it(`should not include final closing ${braceName} in the URL when a hash anchor exists`, () => {
const result = autolinker.link(
`Click here ${openBraceChar}google.com#abc${closeBraceChar} for more details`
);
expect(result).toBe(
`Click here ${openBraceChar}<a href="http://google.com#abc">google.com#abc</a>${closeBraceChar} for more details`
);
});
});
it(`when there are multiple brackets surrounding the URL, should exclude them all`, () => {
const result = autolinker.link(`(Websites {like [google.com/path]})`);
expect(result).toBe(
`(Websites {like [<a href="http://google.com/path">google.com/path</a>]})`
);
});
it(`when there are multiple brackets surrounding the URL including punctuation, should exclude the braces and the punctuation`, () => {
const result = autolinker.link(`(Websites {like [google.com/path.]!}?)`);
expect(result).toBe(
`(Websites {like [<a href="http://google.com/path">google.com/path</a>.]!}?)`
);
});
it(`when there are brackets surrounding the URL and extraneous close brackets inside the URL, should only exclude the ones from the end`, () => {
const result = autolinker.link(`(Websites {like [google.com/path))}]s]})`);
expect(result).toBe(
`(Websites {like [<a href="http://google.com/path))}]s">google.com/path))}]s</a>]})`
);
});
describe(`parenthesis-specific handling >`, () => {
it(`should include escaped parentheses in the URL`, () => {
const result = autolinker.link(
"Here's an example from CodingHorror: http://en.wikipedia.org/wiki/PC_Tools_%28Central_Point_Software%29"
);
expect(result).toBe(
'Here\'s an example from CodingHorror: <a href="http://en.wikipedia.org/wiki/PC_Tools_%28Central_Point_Software%29">en.wikipedia.org/wiki/PC_Tools_(Central_Point_Software)</a>'
);
});
});
describe('square bracket-specific handling >', () => {
it('should include escaped square brackets in the URL', () => {
let result = autolinker.link(
"Here's an example from CodingHorror: http://en.wikipedia.org/wiki/PC_Tools_%5BCentral_Point_Software%5D"
);
expect(result).toBe(
'Here\'s an example from CodingHorror: <a href="http://en.wikipedia.org/wiki/PC_Tools_%5BCentral_Point_Software%5D">en.wikipedia.org/wiki/PC_Tools_[Central_Point_Software]</a>'
);
});
it(`should correctly accept square brackets such as PHP array representation in query strings`, () => {
let result = autolinker.link(
"Here's an example: http://example.com/foo.php?bar[]=1&bar[]=2&bar[]=3"
);
expect(result).toBe(
`Here's an example: <a href="http://example.com/foo.php?bar[]=1&bar[]=2&bar[]=3">example.com/foo.php?bar[]=1&bar[]=2&bar[]=3</a>`
);
});
it(`should correctly accept square brackets such as PHP array
representation in query strings, when the entire URL is surrounded
by square brackets
`, () => {
let result = autolinker.link(
"Here's an example: [http://example.com/foo.php?bar[]=1&bar[]=2&bar[]=3]"
);
expect(result).toBe(
`Here's an example: [<a href="http://example.com/foo.php?bar[]=1&bar[]=2&bar[]=3">example.com/foo.php?bar[]=1&bar[]=2&bar[]=3</a>]`
);
});
});
describe('curly bracket-specific handling >', () => {
it('should include escaped curly brackets in the URL', () => {
let result = autolinker.link(
"Here's an example from CodingHorror: http://en.wikipedia.org/wiki/PC_Tools_%7BCentral_Point_Software%7D"
);
expect(result).toBe(
'Here\'s an example from CodingHorror: <a href="http://en.wikipedia.org/wiki/PC_Tools_%7BCentral_Point_Software%7D">en.wikipedia.org/wiki/PC_Tools_{Central_Point_Software}</a>'
);
});
it(`should correctly accept curly brackets such as a sharepoint url`, () => {
let result = autolinker.link(
"Here's an example: https://gohub.sharepoint.com/example/doc.aspx?sourcedoc={foobar}&action=edit"
);
expect(result).toBe(
`Here's an example: <a href="https://gohub.sharepoint.com/example/doc.aspx?sourcedoc={foobar}&action=edit">gohub.sharepoint.com/example/doc.aspx?sourcedoc={foobar}&action=edit</a>`
);
});
it(`should correctly accept curly brackets such as a sharepoint url,
when the entire URL is surrounded by square brackets`, () => {
let result = autolinker.link(
"Here's an example: https://gohub.sharepoint.com/example/doc.aspx?sourcedoc={foobar}&action=edit"
);
expect(result).toBe(
`Here's an example: <a href="https://gohub.sharepoint.com/example/doc.aspx?sourcedoc={foobar}&action=edit">gohub.sharepoint.com/example/doc.aspx?sourcedoc={foobar}&action=edit</a>`
);
});
it(`should handle accepting nested curly brackets at end of URL`, () => {
let result = autolinker.link(
"Here's an example: http://gohub.sharepoint/example/make-payment?props={%22params%22:{%22loanId%22:%220349494%22}}"
);
expect(result).toBe(
`Here's an example: <a href="http://gohub.sharepoint/example/make-payment?props={%22params%22:{%22loanId%22:%220349494%22}}">gohub.sharepoint/example/make-payment?props={"params":{"loanId":"0349494"}}</a>`
);
});
});
});
describe('Special character handling >', () => {
it('should include $ in URLs', () => {
let result = autolinker.link(
'Check out pair programming: http://c2.com/cgi/wiki$?VirtualPairProgramming'
);
expect(result).toBe(
'Check out pair programming: <a href="http://c2.com/cgi/wiki$?VirtualPairProgramming">c2.com/cgi/wiki$?VirtualPairProgramming</a>'
);
});
it('should include $ in URLs with query strings', () => {
let result = autolinker.link(
'Check out the image at http://server.com/template?fmt=jpeg&$base=700.'
);
expect(result).toBe(
'Check out the image at <a href="http://server.com/template?fmt=jpeg&$base=700">server.com/template?fmt=jpeg&$base=700</a>.'
);
});
it('should include * in URLs', () => {
let result = autolinker.link(
'Google from wayback http://wayback.archive.org/web/*/http://google.com'
);
expect(result).toBe(
'Google from wayback <a href="http://wayback.archive.org/web/*/http://google.com">wayback.archive.org/web/*/http://google.com</a>'
);
});
it('should include * in URLs with query strings', () => {
let result = autolinker.link(
'Twitter search for bob smith https://api.twitter.com/1.1/users/search.json?count=20&q=Bob+*+Smith'
);
expect(result).toBe(
'Twitter search for bob smith <a href="https://api.twitter.com/1.1/users/search.json?count=20&q=Bob+*+Smith">api.twitter.com/1.1/users/search.json?count=20&q=Bob+*+Smith</a>'
);
});
it('should include ^ in URLs with query strings', () => {
let result = autolinker.link(
'Test caret url: https://sourcegraph.yelpcorp.com/search?q=repo:^services&patternType=literal'
);
expect(result).toBe(
'Test caret url: <a href="https://sourcegraph.yelpcorp.com/search?q=repo:^services&patternType=literal">sourcegraph.yelpcorp.com/search?q=repo:^services&patternType=literal</a>'
);
});
it("should include ' in URLs", () => {
let result = autolinker.link(
"You are a star http://en.wikipedia.org/wiki/You're_a_Star/"
);
expect(result).toBe(
'You are a star <a href="http://en.wikipedia.org/wiki/You\'re_a_Star/">en.wikipedia.org/wiki/You\'re_a_Star</a>'
);
});
it("should include ' in URLs with query strings", () => {
let result = autolinker.link("Test google search https://google.com/#q=test's");
expect(result).toBe(
'Test google search <a href="https://google.com/#q=test\'s">google.com/#q=test\'s</a>'
);
});
it('should include [ and ] in URLs with query strings', () => {
let result = autolinker.link(
'Go to https://example.com/api/export/873/?a[]=10&a[]=9&a[]=8&a[]=7&a[]=6 today'
);
expect(result).toBe(
'Go to <a href="https://example.com/api/export/873/?a[]=10&a[]=9&a[]=8&a[]=7&a[]=6">example.com/api/export/873/?a[]=10&a[]=9&a[]=8&a[]=7&a[]=6</a> today'
);
});
it('should handle an example Google Maps URL with query string', () => {
let result = autolinker.link(
"google.no/maps/place/Gary's+Deli/@52.3664378,4.869345,18z/data=!4m7!1m4!3m3!1s0x47c609c14a6680df:0x643f005113531f15!2sBeertemple!3b1!3m1!1s0x0000000000000000:0x51a8a6adb4307be6?hl=no"
);
expect(result).toBe(
'<a href="http://google.no/maps/place/Gary\'s+Deli/@52.3664378,4.869345,18z/data=!4m7!1m4!3m3!1s0x47c609c14a6680df:0x643f005113531f15!2sBeertemple!3b1!3m1!1s0x0000000000000000:0x51a8a6adb4307be6?hl=no">google.no/maps/place/Gary\'s+Deli/@52.3664378,4.869345,18z/data=!4m7!1m4!3m3!1s0x47c609c14a6680df:0x643f005113531f15!2sBeertemple!3b1!3m1!1s0x0000000000000000:0x51a8a6adb4307be6?hl=no</a>'
);
});
it('should handle emoji', () => {
let result = autolinker.link('Joe went to http://emoji🐰🦊town🧞♀️🧜🏻♀️.com/?emoji=👨🏾🚀');
expect(result).toBe(
'Joe went to <a href="http://emoji🐰🦊town🧞♀️🧜🏻♀️.com/?emoji=👨🏾🚀">emoji🐰🦊town🧞♀️🧜🏻♀️.com/?emoji=👨🏾🚀</a>'
);
});
it('should decode emojis', () => {
var result = autolinker.link(
'Danish flag emoji: https://emojipedia.org/%F0%9F%87%A9%F0%9F%87%B0'
);
expect(result).toBe(
'Danish flag emoji: <a href="https://emojipedia.org/%F0%9F%87%A9%F0%9F%87%B0">emojipedia.org/🇩🇰</a>'
);
});
it('should HTML-encode escape-encoded special characters', () => {
var result = autolinker.link('Link: http://example.com/%3c%3E%22%27%26');
expect(result).toBe(
'Link: <a href="http://example.com/%3c%3E%22%27%26">example.com/<>"'&</a>'
);
});
});
it('should automatically link a URL with a complex hash (such as a Google Analytics url)', () => {
let result = autolinker.link(
'Joe went to https://google.com/analytics/web/?pli=1#my-reports/Obif-Y6qQB2xAJk0ZZE1Zg/a4454143w36378534p43704543/%3F.date00%3D20120314%26_.date01%3D20120314%268534-table.rowStart%3D0%268534-table.rowCount%3D25/ and analyzed his analytics'
);
expect(result).toBe(
'Joe went to <a href="https://google.com/analytics/web/?pli=1#my-reports/Obif-Y6qQB2xAJk0ZZE1Zg/a4454143w36378534p43704543/%3F.date00%3D20120314%26_.date01%3D20120314%268534-table.rowStart%3D0%268534-table.rowCount%3D25/">google.com/analytics/web/?pli=1#my-reports/Obif-Y6qQB2xAJk0ZZE1Zg/a4454143w36378534p43704543/?.date00=20120314&_.date01=20120314&8534-table.rowStart=0&8534-table.rowCount=25</a> and analyzed his analytics'
);
});
it("should remove trailing slash from 'http://yahoo.com/'", () => {
let result = autolinker.link('Joe went to http://yahoo.com/.');
expect(result).toBe('Joe went to <a href="http://yahoo.com/">yahoo.com</a>.');
});
it("should remove trailing slash from 'http://yahoo.com/sports/'", () => {
let result = autolinker.link('Joe went to http://yahoo.com/sports/.');
expect(result).toBe('Joe went to <a href="http://yahoo.com/sports/">yahoo.com/sports</a>.');
});
describe('multiple dots handling', () => {
it('should autolink a url with multiple dots in the path', () => {
var result = autolinker.link(
'https://gitlab.example.com/space/repo/compare/master...develop'
);