Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Empty hash at the end of URL causes page reload in HTML5 mode #10397

Closed
dtritus opened this issue Dec 10, 2014 · 4 comments
Closed

Empty hash at the end of URL causes page reload in HTML5 mode #10397

dtritus opened this issue Dec 10, 2014 · 4 comments

Comments

@dtritus
Copy link
Contributor

dtritus commented Dec 10, 2014

For example, If I open http://localhost/#, page is reloaded to http://localhost/.

Looks like issue happens here: https://github.com/angular/angular.js/blob/master/src/ng/location.js#L882

When http://localhost/# loaded $location.absUrl() returns http://localhost/ and $browser.url($location.absUrl(), true) called, which causes page reloading.

@petebacondarwin
Copy link
Contributor

OK, so we could probably fix this by comparing after stripping the empty hash.
I don't believe there is any real difference between loading a page with and without an empty hash... Is there anything that I am missing?

@dtritus
Copy link
Contributor Author

dtritus commented Dec 11, 2014

As I understand, this code executed only once, during application bootstrap, so issue happens only if we loading page with an empty hash.

Next workflow works ok: load page without empty hash -> add some hash -> remove hash -> empty hash kept at the end to prevent page reloading (fixed by #10308).

Also, I think you added wrong component label, issue in $location, not in $http.

@petebacondarwin
Copy link
Contributor

@dritus - would you like to try to fix this? We need a unit test the demonstrates the issue and then the fix, which is to strip empty hashes from the initialUrl before testing.

@dtritus
Copy link
Contributor Author

dtritus commented Jan 27, 2015

I can try to fix this, but right now I don't have time.

dtritus pushed a commit to dtritus/angular.js that referenced this issue Feb 4, 2015
If initial url has empty hash at the end, $location replaces it with url without hash causing page reload

Closes angular#10397
dtritus added a commit to dtritus/angular.js that referenced this issue Feb 4, 2015
If initial url has empty hash at the end, $location replaces it with url without hash causing page reload

Closes angular#10397
petebacondarwin pushed a commit that referenced this issue Feb 4, 2015
…the end

If initial url has empty hash at the end, $location replaces it with url
without hash causing an unwanted page reload.

Closes #10397
Closes #10960
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.