1
0
Fork 0

fix: stripPrefix and stripPrefixRegex.

This commit is contained in:
Ludovic Fernandez 2019-09-03 20:32:03 +02:00 committed by Traefiker Bot
parent 770b3739e0
commit f843f260ee
6 changed files with 55 additions and 52 deletions

View file

@ -28,7 +28,8 @@ func TestStripPrefix(t *testing.T) {
Prefixes: []string{},
},
path: "/noprefixes",
expectedStatusCode: http.StatusNotFound,
expectedStatusCode: http.StatusOK,
expectedPath: "/noprefixes",
},
{
desc: "wildcard (.*) requests",
@ -76,7 +77,8 @@ func TestStripPrefix(t *testing.T) {
Prefixes: []string{"/stat/"},
},
path: "/status",
expectedStatusCode: http.StatusNotFound,
expectedStatusCode: http.StatusOK,
expectedPath: "/status",
},
{
desc: "general prefix on matching path",
@ -149,6 +151,8 @@ func TestStripPrefix(t *testing.T) {
require.NoError(t, err)
req := testhelpers.MustNewRequest(http.MethodGet, "http://localhost"+test.path, nil)
req.RequestURI = req.URL.RequestURI()
resp := &httptest.ResponseRecorder{Code: http.StatusOK}
handler.ServeHTTP(resp, req)