Skip to content
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

Allow repeated keys in param_set #63

Open
sckott opened this issue Dec 23, 2016 · 5 comments
Open

Allow repeated keys in param_set #63

sckott opened this issue Dec 23, 2016 · 5 comments
Milestone

Comments

@sckott
Copy link

sckott commented Dec 23, 2016

Right now:

library(urltools)
query <- list(a = 5, a = 6)
url <- "https://httpbin.org"
(url <- param_set(url, names(query)[1], query[[1]]))
#> "https://httpbin.org?a=5"
(url <- param_set(url, names(query)[2], query[[2]]))
#> "https://httpbin.org?a=6"

Some APIs, unfortunately, when there are multiple values allowed passed to the same query param, want user to pass that query param multiple times in the same request, so e.g.,

https://httpbin.org?a=5&a=6

instead of the more reasonable

https://httpbin.org?a=5,6

The Solr HTTP API is another case - where they expect multiple query params of the same name

Would be great if there was a way to allow param_set to set multiple keys of the same name

@hrbrmstr
Copy link
Collaborator

How would:

(url <- param_set(url, names(query)[1], query[[1]]))
(url <- param_set(url, names(query)[2], query[[2]], allow_multiple=TRUE))

be?

You can test that with : https://github.com/hrbrmstr/urltools/commit/fd3f9b000a04220d89eb486e5ce3818be33df66f

The "get" side needs to be tweaked. param_remove() works (removes last one for each call).

@sckott
Copy link
Author

sckott commented Dec 23, 2016

tested, works great for me. thx

@hrbrmstr
Copy link
Collaborator

cool. i'll try to tweak the "get" by end of break which wld enable oliver to get this on CRAN.

@Ironholds
Copy link
Owner

Boink; anything new? I'd like to push a new release soonish

@Ironholds
Copy link
Owner

Boop

@Ironholds Ironholds added this to the 1.8.0 milestone Jan 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants