Skip to content

Commit

Permalink
Recognise 127.0.0.1 as localhost
Browse files Browse the repository at this point in the history
Fixes #316
  • Loading branch information
hadley committed Oct 8, 2023
1 parent 88ea6c1 commit a11c290
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion R/oauth-flow-auth-code.R
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ normalize_redirect_uri <- function(redirect_uri,
lifecycle::deprecate_warn("0.3.0", "oauth_flow_auth_code(host_ip)")
}

localhost <- parsed$hostname == "localhost"
localhost <- parsed$hostname %in% c("localhost", "127.0.0.1")

if (localhost) {
check_installed("httpuv", "desktop OAuth")
Expand Down
3 changes: 3 additions & 0 deletions tests/testthat/test-oauth-flow-auth-code.R
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ test_that("adds port to localhost url", {

redirect <- normalize_redirect_uri("http://localhost")
expect_false(is.null(url_parse(redirect$uri)$port))

redirect <- normalize_redirect_uri("http://127.0.0.1")
expect_false(is.null(url_parse(redirect$uri)$port))
})

test_that("old args are deprecated", {
Expand Down

0 comments on commit a11c290

Please sign in to comment.