From 35951afb9c86adf7354dea4d40cd08ffd31593dc Mon Sep 17 00:00:00 2001 From: Rodrigo Fernandes Date: Tue, 10 Aug 2021 15:38:41 +0100 Subject: [PATCH] fix: Allow encoded path parameters with slashes --- routers/gorillamux/router.go | 2 +- routers/gorillamux/router_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/routers/gorillamux/router.go b/routers/gorillamux/router.go index 4011932db..a47c762e7 100644 --- a/routers/gorillamux/router.go +++ b/routers/gorillamux/router.go @@ -56,7 +56,7 @@ func NewRouter(doc *openapi3.T) (routers.Router, error) { if len(servers) == 0 { servers = append(servers, srv{}) } - muxRouter := mux.NewRouter() /*.UseEncodedPath()?*/ + muxRouter := mux.NewRouter().UseEncodedPath() r := &Router{} for _, path := range orderedPaths(doc.Paths) { pathItem := doc.Paths[path] diff --git a/routers/gorillamux/router_test.go b/routers/gorillamux/router_test.go index d9ad2c9c6..c42d7f835 100644 --- a/routers/gorillamux/router_test.go +++ b/routers/gorillamux/router_test.go @@ -146,7 +146,7 @@ func TestRouter(t *testing.T) { expect(r, http.MethodGet, "/params/a/b/c%2Fd", paramsGET, map[string]string{ "x": "a", "y": "b", - "z": "c/d", + "z": "c%2Fd", }) expect(r, http.MethodGet, "/books/War.and.Peace", paramsGET, map[string]string{ "bookid": "War.and.Peace",