Skip to content

Commit f679d30

Browse files
committed
added ipv6 support to urlparse regex Fixes jquery-archive#2362
1 parent 23ee457 commit f679d30

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
lines changed

js/jquery.mobile.navigation.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
// [15]: ?msg=1234&type=unread
3939
// [16]: #msg-content
4040
//
41-
urlParseRE: /^(((([^:\/#\?]+:)?(?:\/\/((?:(([^:@\/#\?]+)(?:\:([^:@\/#\?]+))?)@)?(([^:\/#\?]+)(?:\:([0-9]+))?))?)?)?((\/?(?:[^\/\?#]+\/+)*)([^\?#]*)))?(\?[^#]+)?)(#.*)?/,
41+
urlParseRE: /^(((([^:\/#\?]+:)?(?:\/\/((?:(([^:@\/#\?]+)(?:\:([^:@\/#\?]+))?)@)?(([^:\/#\?\]\[]+|\[[^\/\]@#?]+\])(?:\:([0-9]+))?))?)?)?((\/?(?:[^\/\?#]+\/+)*)([^\?#]*)))?(\?[^#]+)?)(#.*)?/,
4242

4343
//Parse a URL into a structure that allows easy access to
4444
//all of the URL components by name.

tests/unit/navigation/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<script type="text/javascript">
1919
$.testHelper.setPushStateFor([
2020
"navigation_transitions.js",
21-
"navigation_helper.js",
21+
"navigation_helpers.js",
2222
"navigation_core.js",
2323
"navigation_paths.js"
2424
]);

tests/unit/navigation/navigation_helpers.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,32 @@
127127
same( mua( "?foo=1&bar=2#spaz", p5 ), "http://jqm.com/test.php?foo=1&bar=2#spaz", "query relative and fragment - absolute root" );
128128
});
129129

130+
// https://github.com/jquery/jquery-mobile/issues/2362
131+
test( "ipv6 host support", function(){
132+
// http://www.ietf.org/rfc/rfc2732.txt ipv6 examples for tests
133+
// most definitely not comprehensive
134+
var ipv6_1 = "http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html",
135+
ipv6_2 = "http://[1080:0:0:0:8:800:200C:417A]/index.html",
136+
ipv6_3 = "http://[3ffe:2a00:100:7031::1]",
137+
ipv6_4 = "http://[1080::8:800:200C:417A]/foo",
138+
ipv6_5 = "http://[::192.9.5.5]/ipng",
139+
ipv6_6 = "http://[::FFFF:129.144.52.38]:80/index.html",
140+
ipv6_7 = "http://[2010:836B:4179::836B:4179]",
141+
fromIssue = "http://[3fff:cafe:babe::]:443/foo";
142+
143+
same( $.mobile.path.parseUrl(ipv6_1).host, "[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80");
144+
same( $.mobile.path.parseUrl(ipv6_1).hostname, "[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]");
145+
same( $.mobile.path.parseUrl(ipv6_2).host, "[1080:0:0:0:8:800:200C:417A]");
146+
same( $.mobile.path.parseUrl(ipv6_3).host, "[3ffe:2a00:100:7031::1]");
147+
same( $.mobile.path.parseUrl(ipv6_4).host, "[1080::8:800:200C:417A]");
148+
same( $.mobile.path.parseUrl(ipv6_5).host, "[::192.9.5.5]");
149+
same( $.mobile.path.parseUrl(ipv6_6).host, "[::FFFF:129.144.52.38]:80");
150+
same( $.mobile.path.parseUrl(ipv6_6).hostname, "[::FFFF:129.144.52.38]");
151+
same( $.mobile.path.parseUrl(ipv6_7).host, "[2010:836B:4179::836B:4179]");
152+
same( $.mobile.path.parseUrl(fromIssue).host, "[3fff:cafe:babe::]:443");
153+
same( $.mobile.path.parseUrl(fromIssue).hostname, "[3fff:cafe:babe::]");
154+
});
155+
130156
test( "path.clean is working properly", function(){
131157
var localroot = location.protocol + "//" + location.host + location.pathname,
132158
remoteroot = "http://google.com/",

0 commit comments

Comments
 (0)