From 8d3dc2cbc2c898ef33420d203972eece14c49a68 Mon Sep 17 00:00:00 2001 From: John Bender Date: Tue, 12 Apr 2011 00:22:42 -0700 Subject: [PATCH] query param href/actions require absolute path prefixes when no relative path information is contained in the hash --- js/jquery.mobile.navigation.js | 5 ++--- tests/unit/navigation/navigation_helpers.js | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/js/jquery.mobile.navigation.js b/js/jquery.mobile.navigation.js index 131037d7..7037f805 100644 --- a/js/jquery.mobile.navigation.js +++ b/js/jquery.mobile.navigation.js @@ -44,14 +44,13 @@ // TODO rename to reflect conditional functionality makeAbsolute: function( url ){ var hash = window.location.hash, - isHashPath = path.isPath( hash ), - relativePathname = location.pathname.replace(/^\//, ""); + isHashPath = path.isPath( hash ); if(path.isQuery( url )){ // if the path is a list of query params and the hash is a path // append the query params to it. otherwise use the pathname and append // the query params - return ( isHashPath ? path.stripHash( hash ) : relativePathname ) + url; + return ( isHashPath ? path.stripHash( hash ) : location.pathname ) + url; } // otherwise use the hash as the path prefix with the file and diff --git a/tests/unit/navigation/navigation_helpers.js b/tests/unit/navigation/navigation_helpers.js index 76aac554..6079d565 100644 --- a/tests/unit/navigation/navigation_helpers.js +++ b/tests/unit/navigation/navigation_helpers.js @@ -46,10 +46,10 @@ same( $.mobile.path.makeAbsolute("?foo=bar&bak=baz"), "bar/bing/bang?foo=bar&bak=baz", "appends query string paths to current path"); $.mobile.path.set(""); - same( $.mobile.path.makeAbsolute("?foo=bar&bak=baz"), "tests/unit/navigation/?foo=bar&bak=baz", "uses pathname for empty hash"); + same( $.mobile.path.makeAbsolute("?foo=bar&bak=baz"), "/tests/unit/navigation/?foo=bar&bak=baz", "uses pathname for empty hash"); $.mobile.path.set("bar"); - same( $.mobile.path.makeAbsolute("?foo=bar&bak=baz"), "tests/unit/navigation/?foo=bar&bak=baz", "uses pathname for embedded pages"); + same( $.mobile.path.makeAbsolute("?foo=bar&bak=baz"), "/tests/unit/navigation/?foo=bar&bak=baz", "uses pathname for embedded pages"); }); test( "path.clean is working properly", function(){