Skip to content

Commit 66f15b6

Browse files
committed
Only use hack when needed
1 parent eb97637 commit 66f15b6

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

R/url.R

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -282,9 +282,11 @@ url_build <- function(url) {
282282
# curl url parser esacapes colons in paths which google seems to use
283283
# quite frequently. So we hack the problem away for now, restoring the
284284
# behaviour of httr2 1.1.2
285-
path <- curl::curl_parse_url(url, decode = FALSE)$path
286-
path <- gsub("%3A", ":", path)
287-
curl::curl_modify_url(url, path = I(path))
285+
if (grepl("%3A", url, fixed = TRUE)) {
286+
path <- curl::curl_parse_url(url, decode = FALSE)$path
287+
path <- gsub("%3A", ":", path, fixed = TRUE)
288+
curl::curl_modify_url(url, path = I(path))
289+
}
288290
}
289291

290292
#' Parse query parameters and/or build a string

tests/testthat/test-url.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,8 @@ test_that("encodes params and paths", {
103103

104104
test_that("colons in paths are left as is", {
105105
expect_equal(
106-
url_modify("https://example.com", path = "a:b"),
107-
"https://example.com/a:b"
106+
url_modify("https://example.com", path = "a:b/foo bar/"),
107+
"https://example.com/a:b/foo%20bar/"
108108
)
109109
})
110110

0 commit comments

Comments
 (0)