Skip to content

Commit

Permalink
Merge pull request openshift#211 from arjunrn/urivalidate-empty-path
Browse files Browse the repository at this point in the history
Do not set path when resolving URL path
  • Loading branch information
openshift-merge-robot authored Mar 17, 2022
2 parents f2818dd + f29ed67 commit 0f4d38c
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 0f4d38c

Please sign in to comment.