You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
Repository navigation
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
New unstable 1.1.5 broke $location URL parsing #2860
Since 1.1.5, the $location provider now appends a hash-part to the URL, which it shouldn't!
Using plunkr for the test-case was problematic because of window.location. So, here is a minimal test-case as code that demonstrates the issue. Simply create an html-file with this code. Notice the URL change at the end after opening the page!
EDIT as @jssebastian clarified below: Visiting page.html, with no use of angular routing but only depending on $location, causes an unwanted redirection to page.html#/page.html
The wrong behavior happens in LocationHashbangUrl in $$compose. The $$parse function assigns a value for this.$$path, which in turn causes this.$$url to be non-empty. Then, the $$absUrl will be changed! (which it shouldn't)
Just +1 the annoyance on this one. I had brought $location in to one little directive and the next thing you know my urls were getting all mangled upon pageload. In general our frontend angular uses don't use routeProvider or locationProvider, so the fact it was modifying the urls was quite annoying. Temporary fix: removed $location for window.location as it does what we need for now.
👍 broke here as well... $location.path() is returning starting from the very last slash instead of the whole path. This affects route resolution, none of the routes match any more in my app. Have to roll back to 1.1.4
I think the minimal example at the top of this issue should still demonstrate the issue (it is difficult to provide a plunkr example due to the window.location aspect).
I still don't get the logic of this. It seems like it would be way better
for angular to only rewrite URLs it knows about in the router. This current
design simply doesn't play well with angular used in a heterogeneous
environment with relative but non-angular URLs on the same page.
We're talking about use cases where html5 mode is off and the app is not hosted at "/". I just tested master (which includes the patch) in this scenario: behavior on the test above seems to be identical to behavior of 1.1.5 as far as I could see. The unwanted redirection does not trigger in either version if you set:
(where page.html is the page in the server root where I dumped the code above)... but that hardly ever makes sense in the context of a non-html5 app, and forces one to use absolute links to all assets, which breaks external code (e.g., jquery-ui) that does not do that.
> (where page.html is the page in the server
root where I dumped the code above)... but that hardly ever makes sense in
the context of a non-html5 app, and
forces one to use absolute links to all assets, which breaks external
code (e.g., jquery-ui) that does not do that.
precisely... I've had to just stop using $location b/c I can't live with
that restriction.
We're talking about use cases where html5 mode is off and the app is not
hosted at "/". I just tested master (which includes the patch) in this
scenario: behavior on the test above seems to be identical to behavior of
1.1.5 as far as I could see. The unwanted redirection does not trigger in
either version if you set:
(where page.html is the page in the server root where I dumped the code
above)... but that hardly ever makes sense in the context of a non-html5
app, and forces one to use absolute links to all assets, which breaks
external code (e.g., jquery-ui) that does not do that.
—
Reply to this email directly or view it on GitHubhttps://github.com//issues/2860#issuecomment-20538548
.
Just wanted to clarify, as no one has made it explicit in this thread. The issue is that visiting page.html, with no use of angular routing but only depending on $location, causes an unwanted redirection to page.html#/page.html.
Activity
martinstein commentedon Jun 3, 2013
The wrong behavior happens in
LocationHashbangUrlin$$compose. The$$parsefunction assigns a value forthis.$$path, which in turn causesthis.$$urlto be non-empty. Then, the$$absUrlwill be changed! (which it shouldn't)martinstein commentedon Jun 3, 2013
I am quite sure that the problem was introduced in this commit: 58ef323
michaelnatkin commentedon Jun 5, 2013
Yes, this is biting me too. (I raised it here: https://groups.google.com/forum/?fromgroups=#!topic/angular/dcfC4hfbUZs, no answer yet.)
michaelnatkin commentedon Jun 5, 2013
See also #2833 - this the real source of the problem I believe.
snostorm commentedon Jun 18, 2013
Just +1 the annoyance on this one. I had brought $location in to one little directive and the next thing you know my urls were getting all mangled upon pageload. In general our frontend angular uses don't use routeProvider or locationProvider, so the fact it was modifying the urls was quite annoying. Temporary fix: removed $location for window.location as it does what we need for now.
basarat commentedon Jun 28, 2013
broken for us too
alexgorbatchev commentedon Jun 30, 2013
👍 broke here as well...
$location.path()is returning starting from the very last slash instead of the whole path. This affects route resolution, none of the routes match any more in my app. Have to roll back to 1.1.4petebacondarwin commentedon Jul 1, 2013
Should be fixed in master.
On 30 June 2013 18:52, Alex Gorbatchev notifications@github.com wrote:
petebacondarwin commentedon Jul 1, 2013
Can you give it a try?
alexgorbatchev commentedon Jul 1, 2013
Good job guys, will give it a try!
martinstein commentedon Jul 4, 2013
@petebacondarwin I have tried the current master and it still seems to be broken. Can somebody else confirm this?
petebacondarwin commentedon Jul 4, 2013
Can you provide a running example?
Pete
...from my mobile.
On 4 Jul 2013 15:07, "Martin Stein" notifications@github.com wrote:
martinstein commentedon Jul 4, 2013
I think the minimal example at the top of this issue should still demonstrate the issue (it is difficult to provide a plunkr example due to the window.location aspect).
martinstein commentedon Jul 4, 2013
In which commit was the code regarding the bug fixed? Maybe I based my test on the wrong code...
artjumble commentedon Jul 4, 2013
While not an exhaustive test, I did update and it seems to be fixed for me.
petebacondarwin commentedon Jul 4, 2013
Have a look at this PR: #2969
michaelnatkin commentedon Jul 4, 2013
I still don't get the logic of this. It seems like it would be way better
for angular to only rewrite URLs it knows about in the router. This current
design simply doesn't play well with angular used in a heterogeneous
environment with relative but non-angular URLs on the same page.
Michael Natkin
CTO
http://ChefSteps.com http://chefsteps.com/
On Thu, Jul 4, 2013 at 11:28 AM, Pete Bacon Darwin <notifications@github.com
jssebastian commentedon Jul 5, 2013
@petebacondarwin: #2969 does not affect/fix this issue.
We're talking about use cases where html5 mode is off and the app is not hosted at "/". I just tested master (which includes the patch) in this scenario: behavior on the test above seems to be identical to behavior of 1.1.5 as far as I could see. The unwanted redirection does not trigger in either version if you set:
(where page.html is the page in the server root where I dumped the code above)... but that hardly ever makes sense in the context of a non-html5 app, and forces one to use absolute links to all assets, which breaks external code (e.g., jquery-ui) that does not do that.
michaelnatkin commentedon Jul 5, 2013
precisely... I've had to just stop using $location b/c I can't live with
that restriction.
Michael Natkin
CTO
http://ChefSteps.com http://chefsteps.com/
On Fri, Jul 5, 2013 at 1:57 PM, jssebastian notifications@github.comwrote:
martinstein commentedon Jul 8, 2013
I agree with @jssebastian : #2969 does not fix this, since that pull request only concerns html5mode. But the problem here occurs in hashbangMode.
jssebastian commentedon Jul 8, 2013
Just wanted to clarify, as no one has made it explicit in this thread. The issue is that visiting
page.html, with no use of angular routing but only depending on $location, causes an unwanted redirection topage.html#/page.html.basarat commentedon Aug 1, 2013
Fixed for me. Put the following in my html head:
wmayner commentedon Sep 30, 2013
👍
jeffbcross commentedon Mar 27, 2014
If this is still broken for anyone in 1.3 or 1.2 latest, feel free to reopen this issue with an updated plunker.