Skip to content

Commit

Permalink
Export IsLocalhost
Browse files Browse the repository at this point in the history
Signed-off-by: aeneasr <aeneas@ory.sh>
  • Loading branch information
aeneasr committed Apr 17, 2019
1 parent d6f8962 commit a95ea09
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions authorize_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,10 @@ func IsValidRedirectURI(redirectURI *url.URL) bool {
}

func IsRedirectURISecure(redirectURI *url.URL) bool {
return !(redirectURI.Scheme == "http" && !isLocalhost(redirectURI))
return !(redirectURI.Scheme == "http" && !IsLocalhost(redirectURI))
}

func isLocalhost(redirectURI *url.URL) bool {
func IsLocalhost(redirectURI *url.URL) bool {
hn := redirectURI.Hostname()
return strings.HasSuffix(hn, ".localhost") || hn == "127.0.0.1" || hn == "localhost"
}
2 changes: 1 addition & 1 deletion authorize_helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func TestIsLocalhost(t *testing.T) {
{expect: true, rawurl: "https://test.localhost"},
} {
u, _ := url.Parse(c.rawurl)
assert.Equal(t, c.expect, isLocalhost(u), "case %d", k)
assert.Equal(t, c.expect, IsLocalhost(u), "case %d", k)
}
}

Expand Down

0 comments on commit a95ea09

Please sign in to comment.