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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Getting base url from route give different results #38972
Comments
This is simply a difference in the implementations of how the url is returned. They are equivalent, but |
@atscott thanks for answer. It doesn't matter to this issue, but ngrx router-store compares these fields. |
Hey everyone, We got bit by @ngrx/router-store causing the extra redirect to '/' because it think's it's out of sync with the router after upgrading from v7 to v10. As a temporary fix, you can modify the DefaultUrlSerializer to strip out that leading '/' to keep the router-store happy. I haven't had a time to spin up a repro app, but I think it's initial activations that are redirected. The router-store gets initially set to url: '' (I think this is the routers currentUrlTree initial value that get passed over) and then after a cancelled navigation (due to UrlTree redirect), the router will serialize the empty url and return '/'. The router-store compares those two values and fires a 2nd navigation that starts racing against your intended redirect. Here's the snippet we're using as a temporary local fix. There's a LOT of extra logic in the guts of the serializer, so this was a cheap/clean way to manually strip out the leading '/' after the default serializer has run.
|
馃悶 bug report
Affected Package
The issue is caused by package @angular/routerIs this a regression?
I don't knowDescription
Hello everyone.
I found strange behaviour in package @angular/router.
When angular app is starting, router has a emptyUrlTree in field currentUrlTree.
Then router creates field routerState based on currentUrlTree.
When I get url from (router.url) I have "/", but when I get url from (router.routerState.snapshot.url) I have empty string
I guess this behaviour is unexpected
馃敩 Minimal Reproduction
Just look at console
https://codesandbox.io/s/lingering-waterfall-bfnx4
馃實 Your Environment
Angular Version:
The text was updated successfully, but these errors were encountered: