-
Notifications
You must be signed in to change notification settings - Fork 27.4k
fix(ngRoute): dont duplicate optional params into query #10689
Conversation
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project, in which case you'll need to sign a Contributor License Agreement (CLA) at https://cla.developers.google.com/. If you've already signed a CLA, it's possible we don't have your GitHub username or you're using a different email address. Check the information on your CLA or see this help article on setting the email on your git commits. Once you've done that, please reply here to let us know. If you signed the CLA as a corporation, please let us know the company's name. |
This sounds reasonable to me but I think the implementation can be much more simple: updateParams: function(newParams) {
if (this.current && this.current.$$route) {
newParams = angular.extend({}, this.current.params, newParams);
$location.path(interpolate(this.current.$$route.originalPath, newParams))
.search(newParams);
}
else {
throw $routeMinErr('norout', 'Tried updating route when with no current route');
}
} |
Corporate CLA just sent over (D2L Corporation) |
@shahata Yeah that was my first alternative suggestion - I'll push the change |
When calling updateParams with properties which were optional, but previously undefined, they would be duplicated into the query params as well as into the path.
We sent over details about the new Google Group based CLA authorization on Monday. Haven't heard back, but maybe we're good to go? |
@shahata - can you check with the guys in the office that the CLA is good then look at merging this when you are happy with it? |
@shahata @petebacondarwin Alright, actually got the e-mail back now, CLA should be good to go |
CLAs look good, thanks! |
When calling updateParams with properties which were optional, but previously undefined, they would be duplicated into the query params as well as into the path. Closes #10689
When calling updateParams with properties which were optional, but
previously undefined, they would be duplicated into the query params as
well as into the path.
jsfiddle reproduction
From
#updateParams
docs:In the actual implementation of updateParams the "remaining properties" are determined prior to interpolation by checking if the
pathParam
for the givenkey
has a value; however, optional parameters may not exist inpathParams
.Alternative fixes might include
interpolate
before separatingsearchParams
, since it will remove matched keys from the passed innewParams
object.pathParams
object (switchRouteMatcher L536,if (key && val)
->if(key)
) and then check for the property as opposed to truthiness