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":