Closed gserg closed 4 years ago
Confirming the same issue here and that it is resolved by reverting to v1.0.18.
https://github.com/ui-router/core/commit/23742e3 was released with 1.0.20, fixing a regression in 1.0.19 that sounds like the same thing here, but did not fix this issue.
Serving a page from /foo
with no base
element (but in "HTML5 mode" with an effective base of /
) will result in a ui-sref
to a state with path /bar
going to /foo/bar
(instead of the expected /bar
).
We've seen this too
This is the line that is the culprit: https://github.com/angular-ui/ui-router/commit/cd426e53d879fda9bcde9efa4062fdef4fc0a34a#diff-6978271205a73d1a084ce370967b7b7bR74.
baseHref() {
return this._baseHref || (this._baseHref = this.$browser.baseHref() || this.$window.location.pathname);
}
In our case we have a base tag <base href="" />
, so the empty string triggers the ||
test to continue, but I can easily imagine something falsey returned if the base tag isn't there too.
Same issue here. We did not have any baseHref
defined and upgarding to 10.0.19/10.0.20 caused a random state's path element to be prepended to the URLs returned by $state.href()
. Adding a <base href="/" />
to the html seems to have fixed it for us.
I have the same problem with with 1.0.20
Adding a
<base href="/" />
to the html seems to have fixed it for us.
Worked for me, thanks @jkytomaki !
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
This does not mean that the issue is invalid. Valid issues may be reopened.
Thank you for your contributions.
This issue tracker is for Bug Reports and Feature Requests only.
Please direct requests for help to StackOverflow. See http://bit.ly/UIR-SOF for details.
This is a (check one box):
My version of UI-Router is: 1.0.19
Bug Report
Current Behavior:
I have two links in menu:
html5Mode is enabled, <base> is omitted
When I open http://localhost/ URLs for all links are calculated correctly:
But when I open direct URL http://localhost/state1/param11 the links are broken:
Expected Behavior:
All links have correct URLs when open direct URL of some state
Link to Plunker that reproduces the issue:
http://plnkr.co/edit/f10MMFiS6G6lxvsboPR3?p=preview
NB! Because this test requires to change URL manually, you need to download code from plunker and run as simple SPA.
There is my config for nginx server:
(also src="_main.js" must be replaced by src="/_main.js" in index.html)
With ui-router v1.0.18 everything works fine :)
PS maybe this issue is related to https://github.com/angular-ui/ui-router/commit/cd426e5 fix