Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

Encoding of arrays in GET params. #3919

Closed
wants to merge 1 commit into from
Closed

Encoding of arrays in GET params. #3919

wants to merge 1 commit into from

Conversation

willfarrell
Copy link

fix($http) change buildUrl to allow for better array support

Arrays of length one would be sent a key-value pair ({a:[1]} -> a=1). On the server side an additional check would be required. Not all third party APIs have a check/autofix for this. Adding in []= when value is an array fixes this issue ({a:[1]} -> a[]=1).

@mary-poppins
Copy link

Thanks for the PR!

  • Contributor signed CLA now or in the past
    • If you just signed, leave a comment here with your real name
  • PR's commit messages follow the commit message format

If you need to make changes to your pull request, you can update the commit with git commit --amend.
Then, update the pull request with git push -f.

Thanks again for your help!

@petebacondarwin
Copy link
Contributor

@willfarrell - we have had a lot of discussion about how to handle arrays as you can see here: #1363.
At the moment we are sticking with this format. If you really want to force a[]=3 style then you can do so by naming the parameter as "a[]" in the first place in angular.
In the long run, we would like to make the parsing and serializing of parameters pluggable.

@willfarrell
Copy link
Author

Thanks for the explanation Pete. I originally tried using {params:{'a[]':1}} but angular encoded the uri to &a%5B%5D=1. I can't speak for all servers but in node it won't catch this as an array. That's is why I wrote the commit. For now I've added an additional check on the server side but feels like a bandaid solution. A pluggable serializing of parameters would be interesting to see.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants