-
Notifications
You must be signed in to change notification settings - Fork 27.5k
Force refreshing on a route causes $location.path() to be wrong. #2762
Comments
I see this too. Looks like a regression introduced in 1.1.5, as it was working fine in 1.1.4. The only precondition to trigger this is to load the url without |
Seeing the same thing and can corroborate the part where it was working in 1.1.4 I have a few routes in my app with varying lengths and the behavior I'm seeing is that the last slash and stuff behind it is gone. So a route like /display/foo/123 becomes /display/foo and something like /create/foo becomes /create |
Ah, and there was me thinking it could just be me being silly! lol. I'm going to test in 1.1.4 to double check that this has been introduced in 1.1.5 and report back. |
I can confirm that this bug was definitely introduced in v1.1.5; v1.1.4 works fine. |
|
Actually #2774 is a duplicate of this one! |
I was just about to say... You can't close them both! 😄 |
I think the issue is here https://github.com/angular/angular.js/blob/master/src/ng/location.js#L504 |
You can workaround the issue in 1.1.5 by adding |
Adding a element is not a good solution. It changes the way the browser handles relative paths and breaks many third-party libraries/widgets, especially those that use urls in SVG like some color pickers. |
Are you guys setting What @clkao mentioned is not a workaround, but a requirement for the router to work properly. if you don't set |
@IgorMinar I wasn't until @clkao pointed it out, but now I am. Perhaps this needs to be made a bit clearer somewhere in the documentation... Plus I'd put the tag into the Yeoman generator-angular project with a dummy value, as that'll force people to notice! |
With the recent refactoring of $location service we changed this behavior resulting in a regression. Previously we thought that html5 mode always required base[href] to be set in order for urls to resolve properly. It turns out that base[href] is problematic because it makes anchor urls (#foo) to always resolve to the base url, which is almost always incorrect and results in all anchors links and other anchor urls (e.g. svg references) to be broken. For this reason, we should now start recommending that people just deploy to root context (/) and not set the base[href] when using the html5 mode (push/pop history state). If it's impossible to deploy to the root context then either all urls in the app must be absolute or base[href] must be set with the caveat that anchor urls in such app won't work. Closes angular#2762
so it turns out that base[href] approach has some issues. see the commit message of 2bc62ce for more info. |
Here's an idea that would help: #2805 |
With the recent refactoring of $location service we changed this behavior resulting in a regression. Previously we thought that html5 mode always required base[href] to be set in order for urls to resolve properly. It turns out that base[href] is problematic because it makes anchor urls (#foo) to always resolve to the base url, which is almost always incorrect and results in all anchors links and other anchor urls (e.g. svg references) to be broken. For this reason, we should now start recommending that people just deploy to root context (/) and not set the base[href] when using the html5 mode (push/pop history state). If it's impossible to deploy to the root context then either all urls in the app must be absolute or base[href] must be set with the caveat that anchor urls in such app won't work. Closes angular#2762
When I navigate to a route such as
http://www.test.com/products/management
and force a refresh, the$routeProvider
fails to match it against any routes and pushes me back tohttp://www.test.com/products
(not even a valid route!). I think that this is because$location.path()
incorrectly reports the current path as/management
.Here's my route configuration for reference:
The text was updated successfully, but these errors were encountered: