From 0c449121278c3711d376da97aa78e80663d58752 Mon Sep 17 00:00:00 2001 From: Jeffrey Lembeck Date: Thu, 25 Oct 2012 10:23:22 -0700 Subject: [PATCH 1/3] Changed urlParseRE to ignore space at beginning. This is expected behavior in browsers. This used to result in pages changing to "%20destination.html" instead of the now "destination.html". Fixes issue #4882 --- js/jquery.mobile.navigation.js | 2 +- tests/unit/navigation/navigation_core.js | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/js/jquery.mobile.navigation.js b/js/jquery.mobile.navigation.js index 40ce3164080..7527c718d7c 100644 --- a/js/jquery.mobile.navigation.js +++ b/js/jquery.mobile.navigation.js @@ -38,7 +38,7 @@ // [15]: ?msg=1234&type=unread // [16]: #msg-content // - urlParseRE: /^(((([^:\/#\?]+:)?(?:\/\/((?:(([^:@\/#\?]+)(?:\:([^:@\/#\?]+))?)@)?(([^:\/#\?]+)(?:\:([0-9]+))?))?)?)?((\/?(?:[^\/\?#]+\/+)*)([^\?#]*)))?(\?[^#]+)?)(#.*)?/, + urlParseRE: /^\s*(((([^:\/#\?]+:)?(?:\/\/((?:(([^:@\/#\?]+)(?:\:([^:@\/#\?]+))?)@)?(([^:\/#\?]+)(?:\:([0-9]+))?))?)?)?((\/?(?:[^\/\?#]+\/+)*)([^\?#]*)))?(\?[^#]+)?)(#.*)?/, //Parse a URL into a structure that allows easy access to //all of the URL components by name. diff --git a/tests/unit/navigation/navigation_core.js b/tests/unit/navigation/navigation_core.js index f363307f071..3ba602b9e07 100644 --- a/tests/unit/navigation/navigation_core.js +++ b/tests/unit/navigation/navigation_core.js @@ -535,4 +535,18 @@ } ]); }); + + asyncTest( "external page is accessed correctly even if it has a space in the url", function(){ + $.testHelper.pageSequence([ + function(){ + $.mobile.changePage( " external.html" ); + }, + + function(){ + ok( $.mobile.activePage.attr( "id" ), "external-test", "the correct page is loaded" ); + start(); + } + ]); + }); + })(jQuery); From 7a7601a30f818c62495a740ad16604148c70553a Mon Sep 17 00:00:00 2001 From: Jeffrey Lembeck Date: Fri, 26 Oct 2012 08:15:11 -0700 Subject: [PATCH 2/3] Changing test to make sure it fails when code change is not there --- tests/unit/navigation/navigation_core.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/unit/navigation/navigation_core.js b/tests/unit/navigation/navigation_core.js index 6d1197b46e9..15aff81b95f 100644 --- a/tests/unit/navigation/navigation_core.js +++ b/tests/unit/navigation/navigation_core.js @@ -1313,11 +1313,11 @@ function(){ $.mobile.changePage( " external.html" ); }, - function(){ - ok( $.mobile.activePage.attr( "id" ), "external-test", "the correct page is loaded" ); + ok( $.mobile.activePage.attr( "id" ) === "external-test", "the correct page is loaded" ); start(); } + ]); }); From b62d4e53a846b42ab32356b69b9bb60a72afe61d Mon Sep 17 00:00:00 2001 From: Jeffrey Lembeck Date: Fri, 26 Oct 2012 09:40:24 -0700 Subject: [PATCH 3/3] Changing ok out to equal; it is more appropriate for this test --- tests/unit/navigation/navigation_core.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/navigation/navigation_core.js b/tests/unit/navigation/navigation_core.js index 15aff81b95f..7908135834f 100644 --- a/tests/unit/navigation/navigation_core.js +++ b/tests/unit/navigation/navigation_core.js @@ -1314,7 +1314,7 @@ $.mobile.changePage( " external.html" ); }, function(){ - ok( $.mobile.activePage.attr( "id" ) === "external-test", "the correct page is loaded" ); + equal( $.mobile.activePage.attr( "id" ), "external-test", "the correct page is loaded" ); start(); }