From 596cc0bb419e0cb387d3cb2f3e2fc50f7baa01dd Mon Sep 17 00:00:00 2001 From: Jason Song Date: Thu, 2 Mar 2023 17:49:55 +0800 Subject: [PATCH] fix: use raw path to strip --- middleware/strip.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/middleware/strip.go b/middleware/strip.go index ce8ebfcc..6a8f4437 100644 --- a/middleware/strip.go +++ b/middleware/strip.go @@ -16,6 +16,8 @@ func StripSlashes(next http.Handler) http.Handler { rctx := chi.RouteContext(r.Context()) if rctx != nil && rctx.RoutePath != "" { path = rctx.RoutePath + } else if r.URL.RawPath != "" { + path = r.URL.RawPath } else { path = r.URL.Path } @@ -43,6 +45,8 @@ func RedirectSlashes(next http.Handler) http.Handler { rctx := chi.RouteContext(r.Context()) if rctx != nil && rctx.RoutePath != "" { path = rctx.RoutePath + } else if r.URL.RawPath != "" { + path = r.URL.RawPath } else { path = r.URL.Path }