jquery-archive / jquery-mobile

jQuery Mobile Framework
https://jquerymobile.com
Other
9.69k stars 2.41k forks source link

base href getting incorrectly set to include extra "/" #1195

Closed lylepratt closed 13 years ago

lylepratt commented 13 years ago

I have a url like this:

www.example.com/#/foo/1/

When I go to it, the page's base HREF gets incorrectly set to: < base href="http://www.example.com//offer/1/" >

Note the extra "/" in the URL after the docBase.

It looks like when docLocation is set here its screwing up if location.pathname is just "/":

$base = $head.children("base"),
hostURL = location.protocol + '//' + location.host,
docLocation = path.get( hostURL + location.pathname ),
docBase = docLocation;

It think changing docLocation to this is a solution:

docLocation = (location.pathname == '/') ? hostURL : path.get( hostURL + location.pathname ),
jblas commented 13 years ago

FYI, I landed a fix for this in the HEAD:

https://github.com/jquery/jquery-mobile/commit/d612edd126f478769b7b34b60d2f8a4f5a6a476d

lylepratt commented 13 years ago

Awesome. Thanks for the update. I had created a pull request to fix this, but your fix is more elegant.

toddparker commented 13 years ago

Closing since Kin seems to have fixed this.