Skip to content

Commit

Permalink
fix: query string with % and :// (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
gierlas authored Mar 23, 2023
1 parent 64c8134 commit 1c41826
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func rawPath(r *http.Request) string {
path = "/"
}
// This is absolute URI, split host and port
if strings.Contains(path, "://") {
if r.URL.Host != "" && strings.Contains(path, "://") {
values := strings.SplitN(path, r.URL.Host, 2)
if len(values) == 2 {
path = values[1]
Expand Down
1 change: 1 addition & 0 deletions utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ func Test_rawPath(t *testing.T) {
{URL: "/home", Expected: "/home"},
{URL: "/home?a=b", Expected: "/home"},
{URL: "/home%2F", Expected: "/home%2F"},
{URL: "/oauth/callback?scope=email%20https://www.googleapis.com/auth/userinfo.email%20openid", Expected: "/oauth/callback"},
}
for _, v := range values {
out := rawPath(makeReq(req{url: v.URL}))
Expand Down

0 comments on commit 1c41826

Please sign in to comment.