Skip to content
This repository was archived by the owner on Oct 8, 2021. It is now read-only.

Commit 9431d8a

Browse files
committed
add tests for mobile path getLocation
1 parent 3704130 commit 9431d8a

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

js/jquery.mobile.navigation.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ define( [
5252
// Abstraction to address xss (Issue #4787) in browsers that auto decode the username:pass
5353
// portion of location.href. All references to location.href should be replaced with a call
5454
// to this method so that it can be dealt with properly here
55-
getLocation: function() {
56-
var uri = this.parseUrl( location.href ),
55+
getLocation: function( url ) {
56+
var uri = this.parseUrl( url || location.href ),
5757
encodedUserPass = "";
5858

5959
if( uri.username ){

tests/unit/navigation/navigation_helpers.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,4 +238,17 @@
238238
same( $.mobile.path.isPermittedCrossDomainRequest( fileDocUrl, "file://foo"), false, "two file protocol urls fail");
239239

240240
});
241+
242+
test( "path.getLocation works properly", function() {
243+
equal( $.mobile.path.getLocation("http://example.com/"), "http://example.com/" );
244+
equal( $.mobile.path.getLocation("http://foo@example.com"), "http://foo@example.com" );
245+
equal( $.mobile.path.getLocation("http://foo:bar@example.com"), "http://foo:bar@example.com" );
246+
equal( $.mobile.path.getLocation("http://<foo<:bar@example.com"), "http://%3Cfoo%3C:bar@example.com" );
247+
equal( $.mobile.path.getLocation("http://foo:<bar<@example.com"), "http://foo:%3Cbar%3C@example.com" );
248+
equal( $.mobile.path.getLocation("http://<foo<:<bar<@example.com"), "http://%3Cfoo%3C:%3Cbar%3C@example.com" );
249+
250+
var allUriParts = "http://jblas:password@mycompany.com:8080/mail/inbox?msg=1234&type=unread#msg-content";
251+
252+
equal( $.mobile.path.getLocation( allUriParts ), allUriParts );
253+
});
241254
})(jQuery);

0 commit comments

Comments
 (0)