-
Notifications
You must be signed in to change notification settings - Fork 3k
ui-router unexpectedly cuts href value in a <base> tag #2357
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I think it's intended to end in / so <base href="/application/"> should work |
Unfortunately it does not work. You can check this in plunker app linked above. Normally it is not required to add '/' at the end and it is not good solution forcing users to add '/' at the end. Standard angular router works ok, but of course I prefer to use ui-router because of all states management. |
I can confirm this is a bug. Looking into it |
Seems to be because of this: https://github.com/angular-ui/ui-router/blob/legacy/src/urlRouter.js#L274 |
We are also facing issues with this, as our base tag points to a specific file and in our case whenever composing hrefs using the last character is spliced and it forms an invalid href. |
No, I haven't changed anything in there.
I'm not sure why we're splicing the last character off, but your guess seems plausible (to remove a trailing slash). When the base does end in a slash, does it still make sense to chop it off? If so, this should be a pretty easy PR (only slice if the string ends with a |
It should do a check if its a slash and only slice it then |
This fixes the vanilla PushState location service handling of `base` tags. This change attempts to match the behavior of https://html.spec.whatwg.org/dev/semantics.html#the-base-element If a base tag is '/base/index.html' and a state with a URL of '/foo' is activated, the URL will be '/base/foo'. If the url exactly matches the base tag, it will route to the state matching '/'. This also addresses a longstanding bug where base tags which didn't end in a slash (such as '/base') had their last character stripped (i.e., '/bas'), and therefore didn't work. Now base tags like that should work as described above. Closes ui-router#54 Closes angular-ui/ui-router#2357
Hello,
During my work on making angular app SEO friendly and replacing '#' with html5mode, I've noticed that ui-router cuts base href's last letter resulting in unusable application. For example when we set
hyperlinks
<a ui-sref="someState"
results inhttp://domain/applicatio/someState
instead ofhttp://domain/application/someState
. It eats 'n'. Generaly it eats last letter no matter what we have in href.Example available in plunkr: http://plnkr.co/edit/Gl7hVXA64ssfunHCt7ib?p=preview
The text was updated successfully, but these errors were encountered: