From bea5c5dd9df117a92fa3dbaf91d86be0b0d135a4 Mon Sep 17 00:00:00 2001 From: Artyom Misko Date: Mon, 15 May 2023 18:47:59 +0300 Subject: [PATCH] fixed bug with redirect from swagger/ to index.html through proxy with changed prefix --- swagger.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/swagger.go b/swagger.go index 5752085..cc4032d 100644 --- a/swagger.go +++ b/swagger.go @@ -3,6 +3,7 @@ package echoSwagger import ( "html/template" "net/http" + "net/url" "path/filepath" "regexp" @@ -158,7 +159,8 @@ func EchoWrapHandler(options ...func(*Config)) echo.HandlerFunc { switch path { case "": - _ = c.Redirect(http.StatusMovedPermanently, matches[1]+"/"+"index.html") + indexUrl, _ := url.JoinPath(c.Request().RequestURI, "index.html") + _ = c.Redirect(http.StatusMovedPermanently, indexUrl) case "index.html": _ = index.Execute(c.Response().Writer, config) case "doc.json":