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
Parentheses remains in URL when child auxiliary route outlet path is set to null #24656
Comments
This is exactly what happens to me too. The problem is that I cannot change the url either by |
@bartando In my project, I implemented a custom URL serializer and then regex replaced parentheses. It looks like it's working right now but it's still a hack, not a permanent solution. I honestly don't know if it will cause a problem in the future. Here's my class:
Regex I used |
Thank you very much, this is by far the best solution. At least for now. |
This looks like something with the serialization logic. It would seem you're right, where we should have a check for this scenario, to see if the only child in the UrlTree is the primary outlet and ensure we serialize with slashes in the case rather than This would be great if any community members wanted to pick this one up. Let me know if any of you are interested in helping on this one. |
@jasonaden I'll start working on a fix for this tomorrow evening. |
with my team we are facing the same problem. |
I implemented a similar solution like galtonova's with this class: import {DefaultUrlSerializer, UrlSerializer, UrlTree} from '@angular/router';
export class MyUrlSerializer extends DefaultUrlSerializer implements UrlSerializer {
serialize(tree: UrlTree): string {
return super.serialize(tree).replace(/\(|\)|\w+-\w+:/g, '');
}
} The key part is the regex used in |
I believe I'm experiencing a problem with this with a combination of default routes (through an empty path My code is something along the lines of this
|
@jamsuu Your issue is probably that the Angular Router does not support multiple redirects when resolving a route from a URL. If your user navigates to |
I'm experiencing this as well. I wouldn't mind so much, but if the user refreshes the page, the view fails to load. If the parentheses are removed, it works. It does work when navigated to via router.navigate, but that still leaves this edge case. I'll give the serializer a shot. |
Still having trouble with this in 2019. The serializer helps. Is it intended that apps should generally need to override this? E.g. is it common practice? Obviously there is an API for it, but... I just wonder how often this is done. |
It's 2020 and still no solution? :/ (except the custom serialiser) |
in May 2020. |
…ving auxiliary outlet segment For URLs that use auxiliary route outlets in the second or following path segments, when removing the auxiliary route segment, parenthesis remain for the primary outlet segment. This causes the following error when trying to reload an URL: "Cannot match any route". The commit adds a check for this scenario, serializing the URL as "a/b" instead of "a/(b)". Resolves angular#24656
…ving auxiliary outlet segment (angular#24656) For URLs that use auxiliary route outlets in the second or following path segments, when removing the auxiliary route segment, parenthesis remain for the primary outlet segment. This causes the following error when trying to reload an URL: "Cannot match any route". The commit adds a check for this scenario, serializing the URL as "a/b" instead of "a/(b)". PR Close angular#24656
…ving auxiliary outlet segment (angular#24656) For URLs that use auxiliary route outlets in the second or following path segments, when removing the auxiliary route segment, parenthesis remain for the primary outlet segment. This causes the following error when trying to reload an URL: "Cannot match any route". The commit adds a check for this scenario, serializing the URL as "a/b" instead of "a/(b)". PR Close angular#24656
…ving auxiliary outlet segment (angular#24656) For URLs that use auxiliary route outlets in the second or following path segments, when removing the auxiliary route segment, parenthesis remain for the primary outlet segment. This causes the following error when trying to reload an URL: "Cannot match any route". The commit adds a check for this scenario, serializing the URL as "a/b" instead of "a/(b)". PR Close angular#24656
…ving auxiliary outlet segment (angular#24656) For URLs that use auxiliary route outlets in the second or following path segments, when removing the auxiliary route segment, parenthesis remain for the primary outlet segment. This causes the following error when trying to reload an URL: "Cannot match any route". The commit adds a check for this scenario, serializing the URL as "a/b" instead of "a/(b)". PR Close angular#24656
Added a check to serialize without parentheses if there is only a primary outlet being used. Should fix the issue. |
…ving auxiliary outlet segment (angular#24656) For URLs that use auxiliary route outlets in the second or following path segments, when removing the auxiliary route segment, parenthesis remain for the primary outlet segment. This causes the following error when trying to reload an URL: "Cannot match any route". The commit adds a check for this scenario, serializing the URL as "a/b" instead of "a/(b)". PR Close angular#24656
…ving auxiliary outlet segment (angular#24656) (angular#37163) For URLs that use auxiliary route outlets in the second or following path segments, when removing the auxiliary route segment, parenthesis remain for the primary outlet segment. This causes the following error when trying to reload an URL: "Cannot match any route". The commit adds a check for this scenario, serializing the URL as "a/b" instead of "a/(b)". PR Close angular#24656 PR Close angular#37163
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
…ving auxiliary outlet segment (angular#24656) (angular#37163) For URLs that use auxiliary route outlets in the second or following path segments, when removing the auxiliary route segment, parenthesis remain for the primary outlet segment. This causes the following error when trying to reload an URL: "Cannot match any route". The commit adds a check for this scenario, serializing the URL as "a/b" instead of "a/(b)". PR Close angular#24656 PR Close angular#37163
I'm submitting a...
Current behavior
From the following URL:
/some/(primary/route//auxOutlet:someAuxRoute)
When routed like this:
this.router.navigate( ['/some', { outlets: { auxOutlet: null } }]);
Parentheses remains in URL string:
https://angular-kasves.stackblitz.io/some/(primary/route)
Expected behavior
URL string should be trimmed of parentheses like that:
https://angular-kasves.stackblitz.io/some/primary/route
Demo
https://stackblitz.com/edit/angular-kasves
https://angular-kasves.stackblitz.io/some/primary/route
First, click "Aux On" button. Then click "Aux Off" button.
Reproduction Steps
Route to some child auxiliary route:
this.router.navigate( ['/some', { outlets: { auxOutlet: ['someAuxRoute'] } }]);
URL will be something similar:
https://angular-kasves.stackblitz.io/some/(primary/route//auxOutlet:someAuxRoute)
After that, set auxiliary router outlet path to null:
this.router.navigate( ['/some', { outlets: { auxOutlet: null } }]);
URL will still contain parentheses:
https://angular-kasves.stackblitz.io/some/(primary/route)
The text was updated successfully, but these errors were encountered: