Skip to content

Commit

Permalink
Add workaround
Browse files Browse the repository at this point in the history
  • Loading branch information
jeroen committed Dec 23, 2024
1 parent c56ea88 commit 9b25cf7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
6 changes: 6 additions & 0 deletions R/parser.R
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ curl_parse_url <- function(url, baseurl = NULL, decode = TRUE, params = TRUE){
stopifnot(is.character(url))
stopifnot(length(url) == 1)
baseurl < as.character(baseurl)

# Workaround for #366
if(substr(url, 1, 1) == '#' && (compareVersion(curl_version()$version, "8.8.0") < 0)){
url <- sub('(#.*)?$', url, baseurl)
}

result <- .Call(R_parse_url, url, baseurl)
if(inherits(result, 'ada')){
result <- normalize_ada(result)
Expand Down
7 changes: 4 additions & 3 deletions tests/testthat/test-parser.R
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,9 @@ test_that("Decoding parameters", {
})

test_that("Parse fragment only", {
out <- curl_parse_url("#foo", "http://x.com/a/b/c")
expect_equal(out$path, '/a/b/c')
expect_equal(out$fragment, 'foo')
baseurl <- "http://x.com/a/b/c?bla=123&foo=yolo#foo"
out <- curl_parse_url("#foo", baseurl)
out2 <- curl_parse_url(baseurl)
expect_equal(out, out2)
})

0 comments on commit 9b25cf7

Please sign in to comment.