Skip to content

Commit 5bdf75c

Browse files
committed
Add a few more tests for local urls with numbers
1 parent 715b412 commit 5bdf75c

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

tests/AutolinkerSpec.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,25 @@ describe( "Autolinker", function() {
295295
expect( result ).toBe( 'Joe went to <a href="https://ru.wikipedia.org/wiki/Кириллица?Кириллица=1#Кириллица">ru.wikipedia.org/wiki/Кириллица?Кириллица=1#Кириллица</a>' );
296296
} );
297297

298+
299+
it( 'should match local urls with numbers when prefixed with http://', function() {
300+
var result1 = autolinker.link( 'http://localhost.local001/test' );
301+
expect( result1 ).toBe( '<a href="http://localhost.local001/test">localhost.local001/test</a>' );
302+
303+
var result2 = autolinker.link( 'http://suus111.w10:8090/display/test/AI' );
304+
expect( result2 ).toBe( '<a href="http://suus111.w10:8090/display/test/AI">suus111.w10:8090/display/test/AI</a>' );
305+
} );
306+
307+
308+
it( 'should not match local urls with numbers when NOT prefixed with http://', function() {
309+
var result1 = autolinker.link( 'localhost.local001/test' );
310+
expect( result1 ).toBe( 'localhost.local001/test' );
311+
312+
var result2 = autolinker.link( 'suus111.w10:8090/display/test/AI' );
313+
expect( result2 ).toBe( 'suus111.w10:8090/display/test/AI' );
314+
} );
315+
316+
298317
it( 'should not match an address with multiple dots', function() {
299318
expect( autolinker.link( 'hello:...world' ) ).toBe( 'hello:...world' );
300319
expect( autolinker.link( 'hello:wo.....rld' ) ).toBe( 'hello:wo.....rld' );

tests/matcher/UrlSpec.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ describe( "Autolinker.matcher.Url", function() {
9595
});
9696

9797

98-
it( 'should match any local URL with http before', function() {
98+
it( 'should match any local URL with numbers with http:// before', function() {
9999
var matches = matcher.parseMatches( 'http://localhost.local001/test' );
100100
var othermatches = matcher.parseMatches( 'http://suus111.w10:8090/display/test/AI' );
101101

@@ -105,7 +105,8 @@ describe( "Autolinker.matcher.Url", function() {
105105
MatchChecker.expectUrlMatch( othermatches[ 0 ], 'http://suus111.w10:8090/display/test/AI', 0 );
106106
});
107107

108-
it( 'should not match a local URL that does not have the http before', function() {
108+
109+
it( 'should not match a local URL with numbers that does not have the http:// before', function() {
109110
var matches = matcher.parseMatches( 'localhost.local001/test' );
110111

111112
expect( matches.length ).toBe( 0 );

0 commit comments

Comments
 (0)