query param href/actions require absolute path prefixes when no relative path information is contained in the hash

This commit is contained in:
John Bender 2011-04-12 00:22:42 -07:00
parent 193762da19
commit 8d3dc2cbc2
2 changed files with 4 additions and 5 deletions

View file

@ -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

View file

@ -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(){