Is there any way to tell req_url_query
to not convert a ,
to a %2
? I understand why it is doing but I am just wondering if there is a way to avoid it. I can do a workaround with req_url_path_append
and maybe that is the canonical way of doing this.
thanks in advance
library(httr2)
library(glue)
req <- request("http://example.com")
# Change url components
two_queries <- c("one", "two")
collapsed_query <- paste0(two_queries, collapse = ",")
## automatically converts , to %2
req %>%
req_url_query(q = collapsed_query)
#> <httr2_request>
#> GET http://example.com?q=one%2Ctwo
#> Body: empty
## keep comma
req %>%
req_url_path_append(glue("?q={collapsed_query}"))
#> <httr2_request>
#> GET http://example.com/?q=one,two
#> Body: empty