diff --git a/app/proxy/proxy.go b/app/proxy/proxy.go index a69a76c..b82032d 100644 --- a/app/proxy/proxy.go +++ b/app/proxy/proxy.go @@ -301,7 +301,7 @@ func (h *Http) matchHandler(next http.Handler) http.Handler { if server == "" { server = strings.Split(r.Host, ":")[0] // drop port } - matches := h.Match(server, r.URL.Path) // get all matches for the server:path pair + matches := h.Match(server, r.URL.EscapedPath()) // get all matches for the server:path pair match, ok := getMatch(matches, h.LBSelector) if ok { ctx := context.WithValue(r.Context(), ctxMatch, match) // set match info diff --git a/app/proxy/proxy_test.go b/app/proxy/proxy_test.go index 890518d..7b53999 100644 --- a/app/proxy/proxy_test.go +++ b/app/proxy/proxy_test.go @@ -101,6 +101,20 @@ func TestHttp_Do(t *testing.T) { assert.Contains(t, string(b), "Sorry for the inconvenience") assert.Equal(t, "text/html; charset=utf-8", resp.Header.Get("Content-Type")) } + + { + resp, err := client.Get("http://localhost:" + strconv.Itoa(port) + "/api/test%20%25%20and%20&,%20and%20other%20characters%20@%28%29%5E%21") + require.NoError(t, err) + defer resp.Body.Close() + assert.Equal(t, http.StatusOK, resp.StatusCode) + t.Logf("%+v", resp.Header) + + body, err := io.ReadAll(resp.Body) + require.NoError(t, err) + assert.Equal(t, "response /123/test%20%25%20and%20&,%20and%20other%20characters%20@%28%29%5E%21", string(body)) + assert.Equal(t, "reproxy", resp.Header.Get("App-Name")) + assert.Equal(t, "v1", resp.Header.Get("h1")) + } } func TestHttp_DoWithAssets(t *testing.T) {