Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* `req_headers_redacted()` supports dynamic dots (#647)
* `resp_stream_sse()` now automatically retrieves the next event if the current event contains no data. The data is now returned as a single string (#650).
* `aws_v4_signature()` now works if url contains query parameters (@jeffreyzuber, #645).
* `req_oauth_auth_code()` no longer adds trailing "/" characters to well-formed `redirect_uri` values (@jonthegeek, #646).

# httr2 1.1.0

Expand Down
4 changes: 2 additions & 2 deletions R/oauth-flow-auth-code.R
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ normalize_redirect_uri <- function(redirect_uri,
port = deprecated(),
error_call = caller_env()) {

parsed <- url_parse(redirect_uri)
old <- parsed <- url_parse(redirect_uri)

if (lifecycle::is_present(host_name)) {
lifecycle::deprecate_warn(
Expand Down Expand Up @@ -250,7 +250,7 @@ normalize_redirect_uri <- function(redirect_uri,
}

list(
uri = url_build(parsed),
uri = if (identical(old, parsed)) redirect_uri else url_build(parsed),
localhost = localhost,
can_fetch_code = can_fetch_oauth_code(redirect_uri)
)
Expand Down
15 changes: 10 additions & 5 deletions tests/testthat/test-curl.R
Original file line number Diff line number Diff line change
Expand Up @@ -204,11 +204,16 @@ test_that("can read from clipboard", {
rlang::local_interactive()

clipr::write_clip("curl 'http://example.com' \\\n -H 'A: 1' \\\n -H 'B: 2'")
expect_snapshot({
curl_translate()
# also writes to clip
clipr::read_clip()
})
expect_snapshot(
{
curl_translate()
# also writes to clip
clipr::read_clip()
},
transform = function(x) {
grep("\\\\r", x, value = TRUE, invert = TRUE)
}
)
})

test_that("encode_string2() produces simple strings", {
Expand Down
9 changes: 9 additions & 0 deletions tests/testthat/test-oauth-flow-auth-code.R
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,15 @@ test_that("old args are deprecated", {

})

test_that("valid urls aren't changed", {
# Allow tests to run when is_hosted_session() is TRUE.
local_mocked_bindings(is_hosted_session = function() FALSE)

original_uri <- "http://localhost:8080"
normalized_uri <- normalize_redirect_uri(original_uri)
expect_identical(normalized_uri$uri, original_uri)
})

# ouath_flow_auth_code_parse ----------------------------------------------

test_that("forwards oauth error", {
Expand Down
Loading