Skip to content

Commit 972e878

Browse files
committed
Add tests around autolinking port numbers in URLs.
1 parent fa1bea2 commit 972e878

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

tests/AutolinkerSpec.js

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,36 @@ describe( "Autolinker", function() {
6161
} );
6262

6363

64+
it( "should automatically link URLs with a port number", function() {
65+
var result = autolinker.link( "Joe went to http://yahoo.com:8000 today." );
66+
expect( result ).toBe( 'Joe went to <a href="http://yahoo.com:8000">yahoo.com:8000</a> today.' );
67+
} );
68+
69+
70+
it( "should automatically link URLs with a port number and a following slash", function() {
71+
var result = autolinker.link( "Joe went to http://yahoo.com:8000/ today." );
72+
expect( result ).toBe( 'Joe went to <a href="http://yahoo.com:8000/">yahoo.com:8000</a> today.' );
73+
} );
74+
75+
76+
it( "should automatically link URLs with a port number and a path", function() {
77+
var result = autolinker.link( "Joe went to http://yahoo.com:8000/mysite/page today." );
78+
expect( result ).toBe( 'Joe went to <a href="http://yahoo.com:8000/mysite/page">yahoo.com:8000/mysite/page</a> today.' );
79+
} );
80+
81+
82+
it( "should automatically link URLs with a port number and a query string", function() {
83+
var result = autolinker.link( "Joe went to http://yahoo.com:8000?page=index today." );
84+
expect( result ).toBe( 'Joe went to <a href="http://yahoo.com:8000?page=index">yahoo.com:8000?page=index</a> today.' );
85+
} );
86+
87+
88+
it( "should automatically link URLs with a port number and a hash string", function() {
89+
var result = autolinker.link( "Joe went to http://yahoo.com:8000#page=index today." );
90+
expect( result ).toBe( 'Joe went to <a href="http://yahoo.com:8000#page=index">yahoo.com:8000#page=index</a> today.' );
91+
} );
92+
93+
6494
it( "should NOT automatically link strings of the form 'git:d' (using the heuristic that the domain name does not have a '.' in it)", function() {
6595
var result = autolinker.link( 'Something like git:d should not be linked as a URL' );
6696
expect( result ).toBe( 'Something like git:d should not be linked as a URL' );
@@ -121,6 +151,12 @@ describe( "Autolinker", function() {
121151
expect( result ).toBe( 'Joe went to <a href="http://www.yahoo.com">yahoo.com</a>.' );
122152
} );
123153

154+
155+
it( "should automatically link URLs in the form of 'www.yahoo.com:8000' (with a port number)", function() {
156+
var result = autolinker.link( "Joe went to www.yahoo.com:8000 today" );
157+
expect( result ).toBe( 'Joe went to <a href="http://www.yahoo.com:8000">yahoo.com:8000</a> today' );
158+
} );
159+
124160
} );
125161

126162

@@ -155,6 +191,12 @@ describe( "Autolinker", function() {
155191
expect( result ).toBe( 'Joe went to <a href="http://yahoo.com">yahoo.com</a>.' );
156192
} );
157193

194+
195+
it( "should automatically link URLs in the form of 'www.yahoo.com:8000' (with a port number)", function() {
196+
var result = autolinker.link( "Joe went to yahoo.com:8000 today" );
197+
expect( result ).toBe( 'Joe went to <a href="http://yahoo.com:8000">yahoo.com:8000</a> today' );
198+
} );
199+
158200
} );
159201

160202

0 commit comments

Comments
 (0)