You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
expect(result).toBe('Joe went to <a href="http://localhost:8000#page=index">localhost:8000#page=index</a> today.');
164
164
});
165
165
166
+
166
167
it("should automatically link domain names, paths, query strings, and hashes with numbers in them",function(){
167
168
letresult=autolinker.link("Joe went to https://abc123def.org/path1/2path?param1=value1#hash123z");
168
169
expect(result).toBe('Joe went to <a href="https://abc123def.org/path1/2path?param1=value1#hash123z">abc123def.org/path1/2path?param1=value1#hash123z</a>');
169
170
});
170
171
172
+
171
173
it("should automatically link domain names, paths, query strings, and hashes with dashes in them",function(){
172
174
letresult=autolinker.link("Joe went to https://abc-def.org/his-path/?the-param=the-value#the-hash");
173
175
expect(result).toBe('Joe went to <a href="https://abc-def.org/his-path/?the-param=the-value#the-hash">abc-def.org/his-path/?the-param=the-value#the-hash</a>');
174
176
});
175
177
178
+
176
179
it("should automatically link domain names, paths, query strings, and hashes with the set of allowed special characters in them",function(){
it("should automatically link a URL with accented characters",function(){
182
186
letresult=autolinker.link("Joe went to http://mañana.com/mañana?mañana=1#mañana today.");
183
187
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.');
184
188
});
185
189
190
+
186
191
it("should automatically link cyrillic URLs",function(){
187
192
letresult=autolinker.link("Joe went to https://ru.wikipedia.org/wiki/Кириллица?Кириллица=1#Кириллица");
188
193
expect(result).toBe('Joe went to <a href="https://ru.wikipedia.org/wiki/Кириллица?Кириллица=1#Кириллица">ru.wikipedia.org/wiki/Кириллица?Кириллица=1#Кириллица</a>');
189
194
});
190
195
196
+
191
197
it("should automatically link international domain names",function(){
192
198
letresult1=autolinker.link("Русским гораздо проще набрать россия.рф на клавиатуре.");
193
199
expect(result1).toBe('Русским гораздо проще набрать <a href="http://россия.рф">россия.рф</a> на клавиатуре.');
expect(result3).toBe('Русским гораздо проще набрать <a href="//россия.рф">россия.рф</a> на клавиатуре.');
200
206
});
201
207
208
+
202
209
it("should automatically link domain names represented in punicode",function(){
203
210
letresult1=autolinker.link("For compatibility reasons, xn--d1acufc.xn--p1ai is an acceptable form of an international domain.");
204
211
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.');
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.');
208
215
});
209
216
217
+
210
218
it('should match local urls with numbers when prefixed with http://',function(){
expect(result).toBe('Joe went to <a href="http://yahoo.com">yahoo.com</a> and <a href="http://google.com">google.com</a>');
809
818
});
810
819
820
+
821
+
describe('combination example',()=>{
822
+
823
+
it(`should automatically link all of the URLs of many different forms`,()=>{
824
+
letinputStr=`
825
+
Joe went to http://yahoo.com and http://localhost today along with http://localhost:8000.
826
+
He also had a path on localhost: http://localhost:8000/abc, and a query string: http://localhost:8000?abc
827
+
But who could forget about hashes like http://localhost:8000#abc
828
+
It seems http://www.google.com is a good site, but might want to be secure with https://www.google.com
829
+
Sometimes people just need an IP http://66.102.7.147, and a port like http://10.0.0.108:9000
830
+
Capitalized URLs are interesting: HTTP://WWW.YAHOO.COM
831
+
We all like known TLDs like yahoo.com, but shouldn't go to unknown TLDs like sencha.etc
832
+
And definitely shouldn't go to abc.123
833
+
Don't want to include periods at the end of sentences like http://yahoo.com.
834
+
Sometimes you need to go to a path like yahoo.com/my-page
835
+
And hit query strings like yahoo.com?page=index
836
+
Port numbers on known TLDs are important too like yahoo.com:8000.
837
+
Hashes too yahoo.com:8000/#some-link.
838
+
Sometimes you need a lot of things in the URL like https://abc123def.org/path1/2path?param1=value1#hash123z
839
+
Do you see the need for dashes in these things too https://abc-def.org/his-path/?the-param=the-value#the-hash?
840
+
There's a time for lots and lots of special characters like in https://abc123def.org/-+&@#/%=~_()|\'$*[]?!:,.;/?param1=value-+&@#/%=~_()|\'$*[]?!:,.;#hash-+&@#/%=~_()|\'$*[]?!:,.;z
841
+
Don't forget about good times with unicode https://ru.wikipedia.org/wiki/Кириллица?Кириллица=1#Кириллица
842
+
and this unicode http://россия.рф
843
+
along with punycode http://xn--d1acufc.xn--p1ai
844
+
Oh good old www links like www.yahoo.com
845
+
`;
846
+
847
+
letresult=autolinker.link(inputStr);
848
+
expect(result).toBe(`
849
+
Joe went to <a href="http://yahoo.com">yahoo.com</a> and <a href="http://localhost">localhost</a> today along with <a href="http://localhost:8000">localhost:8000</a>.
850
+
He also had a path on localhost: <a href="http://localhost:8000/abc">localhost:8000/abc</a>, and a query string: <a href="http://localhost:8000?abc">localhost:8000?abc</a>
851
+
But who could forget about hashes like <a href="http://localhost:8000#abc">localhost:8000#abc</a>
852
+
It seems <a href="http://www.google.com">google.com</a> is a good site, but might want to be secure with <a href="https://www.google.com">google.com</a>
853
+
Sometimes people just need an IP <a href="http://66.102.7.147">66.102.7.147</a>, and a port like <a href="http://10.0.0.108:9000">10.0.0.108:9000</a>
854
+
Capitalized URLs are interesting: <a href="HTTP://WWW.YAHOO.COM">YAHOO.COM</a>
855
+
We all like known TLDs like <a href="http://yahoo.com">yahoo.com</a>, but shouldn't go to unknown TLDs like sencha.etc
856
+
And definitely shouldn't go to abc.123
857
+
Don't want to include periods at the end of sentences like <a href="http://yahoo.com">yahoo.com</a>.
858
+
Sometimes you need to go to a path like <a href="http://yahoo.com/my-page">yahoo.com/my-page</a>
859
+
And hit query strings like <a href="http://yahoo.com?page=index">yahoo.com?page=index</a>
860
+
Port numbers on known TLDs are important too like <a href="http://yahoo.com:8000">yahoo.com:8000</a>.
861
+
Hashes too <a href="http://yahoo.com:8000/#some-link">yahoo.com:8000/#some-link</a>.
862
+
Sometimes you need a lot of things in the URL like <a href="https://abc123def.org/path1/2path?param1=value1#hash123z">abc123def.org/path1/2path?param1=value1#hash123z</a>
863
+
Do you see the need for dashes in these things too <a href="https://abc-def.org/his-path/?the-param=the-value#the-hash">abc-def.org/his-path/?the-param=the-value#the-hash</a>?
864
+
There's a time for lots and lots of special characters like in <a href="https://abc123def.org/-+&@#/%=~_()|'$*[]?!:,.;/?param1=value-+&@#/%=~_()|'$*[]?!:,.;#hash-+&@#/%=~_()|'$*[]?!:,.;z">abc123def.org/-+&@#/%=~_()|'$*[]?!:,.;/?param1=value-+&@#/%=~_()|'$*[]?!:,.;#hash-+&@#/%=~_()|'$*[]?!:,.;z</a>
865
+
Don't forget about good times with unicode <a href="https://ru.wikipedia.org/wiki/Кириллица?Кириллица=1#Кириллица">ru.wikipedia.org/wiki/Кириллица?Кириллица=1#Кириллица</a>
866
+
and this unicode <a href="http://россия.рф">россия.рф</a>
867
+
along with punycode <a href="http://xn--d1acufc.xn--p1ai">xn--d1acufc.xn--p1ai</a>
868
+
Oh good old www links like <a href="http://www.yahoo.com">yahoo.com</a>
0 commit comments