You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Query params containing commas result in an extra navigation #16067
[x] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question
Current behavior
When visiting an ng2 URL with a query parameter value containing a comma, ng2 redirects to the same path with all query parameters removed.
Expected behavior
Parameters should not disappear, and the router should properly report the value for the query param.
Minimal reproduction of the problem with instructions
Steps to reproduce:
What is the motivation / use case for changing the behavior?
Our product currently has some parameter values containing commas, and we need to support them.
changed the title [-]Query params containing commas result in a redirect[/-][+]Query params containing commas result in an extra navigation[/+]on Apr 17, 2017
The first navigation is triggered by the Angular2 router
Subsequent navigations are initiated by the interop, most specifically:
functionsetUpLocationSync(ngUpgrade){if(!ngUpgrade.$injector){thrownewError("\n RouterUpgradeInitializer can be used only after UpgradeModule.bootstrap has been called.\n Remove RouterUpgradeInitializer and call setUpLocationSync after UpgradeModule.bootstrap.\n ");}varrouter=ngUpgrade.injector.get(_angular_router.Router);varurl=document.createElement('a');ngUpgrade.$injector.get('$rootScope').$on('$locationChangeStart',function(_,next,__){url.href=next;router.navigateByUrl(url.pathname);});}
The browser's back button also doesn't successfully navigate back in the URL history for parameters containing a comma. To demonstrate this, try the original repro case, but add queryParamsHandling="merge" to the link in team_list.component.html. If you click on a team link, then attempt to use the browser's "back" functionality, the page is not updated.
One addition from me: The setUpLocationSync function has another issue - it drops the hash part of the url.
So the fix probably should be router.navigateByUrl(url.pathname + url.search + url.hash);
Activity
[-]Query params containing commas result in a redirect[/-][+]Query params containing commas result in an extra navigation[/+]vicb commentedon Apr 21, 2017
The first navigation is triggered by the Angular2 router
Subsequent navigations are initiated by the interop, most specifically:
from the router-upgrade
vicb commentedon Apr 21, 2017
Seems like changing
router.navigateByUrl(url.pathname);forrouter.navigateByUrl(url.pathname + url.search);fixes the issuefix(router): forward the query parameters in the ng1 -> ng2 url sync
fix(router): forward the query parameters in the ng1 -> ng2 url sync (a…
bourey commentedon May 24, 2017
While query parameters aren't dropped anymore, it looks like they're still not being handled properly. Now I see a brief flicker in the location bar, which appears to correspond to the URL quickly changing to http://localhost:3000/teams?foo=bar2%2baz, then back to http://localhost:3000/teams?foo=bar,baz.
The browser's back button also doesn't successfully navigate back in the URL history for parameters containing a comma. To demonstrate this, try the original repro case, but add queryParamsHandling="merge" to the link in team_list.component.html. If you click on a team link, then attempt to use the browser's "back" functionality, the page is not updated.
naomiblack commentedon May 24, 2017
re-opening this one. @vicb @mhevery @jasonaden
KKrisu commentedon Jun 20, 2017
One addition from me: The
setUpLocationSyncfunction has another issue - it drops the hash part of the url.So the fix probably should be
router.navigateByUrl(url.pathname + url.search + url.hash);cc @vicb @mhevery @jasonaden @naomiblack
jasonaden commentedon Jun 29, 2017
@KKrisu Yes, looks like you're correct. I'll add that in as well.
2 remaining items
fix(router): encode URLs the same way AngularJS did (closer to spec)
fix(router): encode URLs the same way AngularJS did (closer to spec) (#…
fix(router): encode URLs the same way AngularJS did (closer to spec) (a…
fix(router): forward the query parameters in the ng1 -> ng2 url sync (a…
fix(router): encode URLs the same way AngularJS did (closer to spec) (a…
fix(router): forward the query parameters in the ng1 -> ng2 url sync (a…
fix(router): encode URLs the same way AngularJS did (closer to spec) (a…
angular-automatic-lock-bot commentedon Sep 12, 2019
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.
fix(router): encode URLs the same way AngularJS did (closer to spec) (a…