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

Commit 3740d5e

Browse files
committed
parse the hash to avoid decoding in FF, but use the location object elsewhere to avoid the inclusion of the auth
1 parent 74a8f48 commit 3740d5e

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

js/jquery.mobile.navigation.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,16 @@ define( [
5353
// browsers that auto decode it. All references to location.href should be
5454
// replaced with a call to this method so that it can be dealt with properly here
5555
getLocation: function( url ) {
56-
var uri = url ? this.parseUrl( url ) : this.parseUrl( location.href );
56+
var uri = url ? this.parseUrl( url ) : location,
57+
hash = this.parseUrl( url || location.href ).hash;
5758

58-
return uri.protocol + "//" + uri.host + uri.pathname + uri.search + uri.hash;
59+
// mimic the browser with an empty string when the hash is empty
60+
hash = hash === "#" ? "" : hash;
61+
62+
// Make sure to parse the url or the location object for the hash because using location.hash
63+
// is autodecoded in firefox, the rest of the url should be from the object (location unless
64+
// we're testing) to avoid the inclusion of the authority
65+
return uri.protocol + "//" + uri.host + uri.pathname + uri.search + hash;
5966
},
6067

6168
parseLocation: function() {

0 commit comments

Comments
 (0)