From 4180bc6bdb6eae80bf6e198eb909f189c14fdb4c Mon Sep 17 00:00:00 2001 From: Reid Levesque Date: Wed, 31 Jul 2024 10:36:36 -0400 Subject: [PATCH] fix: Properly parse url in oauth callback Fixes https://github.com/swaggo/echo-swagger/issues/106 --- swagger.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/swagger.go b/swagger.go index b8dc937..47de94c 100644 --- a/swagger.go +++ b/swagger.go @@ -3,6 +3,7 @@ package echoSwagger import ( "html/template" "net/http" + "net/url" "path/filepath" "regexp" @@ -188,7 +189,13 @@ func EchoWrapHandler(options ...func(*Config)) echo.HandlerFunc { } _, _ = c.Response().Writer.Write(doc) default: - c.Request().URL.Path = matches[2] + parsedUrl, err := url.Parse(matches[2]) + if err != nil { + c.Error(err) + + return nil + } + c.Request().URL = parsedUrl http.FileServer(http.FS(swaggerFiles.FS)).ServeHTTP(c.Response(), c.Request()) }