Skip to content
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

Fix location hash being added twice to URL #847

Conversation

oliverguenther
Copy link
Contributor

@oliverguenther oliverguenther commented Sep 16, 2020

In 0192877, a fix was made for #747, adding hashes before or after search params in the location service.

This breaks setting URLs with a single hash such as /home#footer, which is now being added twice - in the path and the search params like so home#footer?#footer

I modified an exemplary add to show this behavior: https://stackblitz.com/edit/angular-uirouter-guglw7

The link is generated in app.component.html: https://stackblitz.com/edit/angular-uirouter-guglw7?file=src%2Fapp%2Fapp.component.html

<a uiSref="home" [uiParams]="{ '#': 'footer' }" role="button">Home footer</a></li>

Click on the "Home footer" link to reproduce this error.

I added a fix to ensure the prefixed hash is only added to one of the parts. To the search path, if it exists, or to the url part if it's empty. I also extended the spec for the case of adding a hash without search.

I also added a test:watch command to test and watch tests locally which seemed to be missing (npm run watch does not exist as documented in contributing.md). Some additional format changes were made by the husky precommit it seems

@oliverguenther
Copy link
Contributor Author

Anything I can do here @christopherthielen ?

@christopherthielen christopherthielen merged commit 3794b25 into ui-router:master Mar 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants