diff options
Diffstat (limited to 'workhorse')
-rw-r--r-- | workhorse/internal/api/api.go | 5 | ||||
-rw-r--r-- | workhorse/main_test.go | 6 |
2 files changed, 9 insertions, 2 deletions
diff --git a/workhorse/internal/api/api.go b/workhorse/internal/api/api.go index 445ca3a94cf..8ab83a1d986 100644 --- a/workhorse/internal/api/api.go +++ b/workhorse/internal/api/api.go @@ -168,7 +168,10 @@ func singleJoiningSlash(a, b string) string { // joinURLPath is taken from reverseproxy.go:joinURLPath func joinURLPath(a *url.URL, b string) (path string, rawpath string) { - if a.RawPath == "" && b == "" { + // Avoid adding a trailing slash if the suffix is empty + if b == "" { + return a.Path, a.RawPath + } else if a.RawPath == "" { return singleJoiningSlash(a.Path, b), "" } diff --git a/workhorse/main_test.go b/workhorse/main_test.go index 4e169b5112f..5729d2412bc 100644 --- a/workhorse/main_test.go +++ b/workhorse/main_test.go @@ -536,7 +536,11 @@ func TestApiContentTypeBlock(t *testing.T) { func TestAPIFalsePositivesAreProxied(t *testing.T) { goodResponse := []byte(`<html></html>`) ts := testhelper.TestServerWithHandler(regexp.MustCompile(`.`), func(w http.ResponseWriter, r *http.Request) { - if r.Header.Get(secret.RequestHeader) != "" && r.Method != "GET" { + url := r.URL.String() + if url[len(url)-1] == '/' { + w.WriteHeader(500) + w.Write([]byte("PreAuthorize request included a trailing slash")) + } else if r.Header.Get(secret.RequestHeader) != "" && r.Method != "GET" { w.WriteHeader(500) w.Write([]byte("non-GET request went through PreAuthorize handler")) } else { |