Skip to content

Escape ascii characters in queries#153

Merged
hadley merged 8 commits intor-lib:mainfrom
boshek:feat/escape-ascii
Jun 23, 2022
Merged

Escape ascii characters in queries#153
hadley merged 8 commits intor-lib:mainfrom
boshek:feat/escape-ascii

Conversation

@boshek
Copy link
Contributor

@boshek boshek commented Jun 14, 2022

Closes #152

Old behaviour

library(httr2)
req <- request("http://example.com")

# Change url components
two_queries <- c("one", "two")
collapsed_query <- paste0(two_queries, collapse = ",")

## automatically converts , to %2
request("http://example.com") %>%
  req_url_query(q = I(collapsed_query))
#> <httr2_request>
#> GET http://example.com?q=one%2Ctwo
#> Body: empty

New behaviour

library(httr2)
req <- request("http://example.com")

# Change url components
two_queries <- c("one", "two")
collapsed_query <- paste0(two_queries, collapse = ",")

## automatically converts , to %2
request("http://example.com") %>%
  req_url_query(q = I(collapsed_query))
#> <httr2_request>
#> GET http://example.com?q=one,two
#> Body: empty

@boshek boshek changed the title Escapeascii characters in queries Escape ascii characters in queries Jun 14, 2022
@hadley
Copy link
Member

hadley commented Jun 23, 2022

Thanks! I did a little tweaking of the code style, and I'll merge momentarily.

@boshek
Copy link
Contributor Author

boshek commented Jun 23, 2022

Great. Caught one little typo which of course kicked off the CI again.

@hadley hadley merged commit ed1de04 into r-lib:main Jun 23, 2022
@boshek boshek deleted the feat/escape-ascii branch June 23, 2022 22:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Escaping ascii characters in queries

2 participants