Skip to content

Commit

Permalink
Do not set path when resolving URL path
Browse files Browse the repository at this point in the history
  • Loading branch information
arjunrn committed Mar 15, 2022
1 parent f2818dd commit f29ed67
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
4 changes: 2 additions & 2 deletions urivalidate.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ func ParseUrls(baseUrl, redirectUrl string) (retBaseUrl, retRedirectUrl *url.URL
}

// resolve references to base url
retBaseUrl = (&url.URL{Scheme: base.Scheme, Host: host, Path: "/"}).ResolveReference(&url.URL{Path: base.Path})
retRedirectUrl = (&url.URL{Scheme: base.Scheme, Host: host, Path: "/"}).ResolveReference(&url.URL{Path: redirect.Path, RawQuery: redirect.RawQuery})
retBaseUrl = (&url.URL{Scheme: base.Scheme, Host: host}).ResolveReference(&url.URL{Path: base.Path})
retRedirectUrl = (&url.URL{Scheme: base.Scheme, Host: host}).ResolveReference(&url.URL{Path: redirect.Path, RawQuery: redirect.RawQuery})
return
}

Expand Down
12 changes: 12 additions & 0 deletions urivalidate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,18 @@ func TestURIValidate(t *testing.T) {
"http://localhost:14000/appauth",
"http://localhost:14000/appauth",
},
{
"Only domain, exact match",
"http://google.com",
"http://google.com",
"http://google.com",
},
{
"Only domain, with subpath",
"http://google.com",
"http://google.com/redirect",
"http://google.com/redirect",
},
{
"Trailing slash",
"http://www.google.com/myapp",
Expand Down

0 comments on commit f29ed67

Please sign in to comment.