From b2ff3d6b197c4ba2c7cd82c01e8e7d9a1c750b7e Mon Sep 17 00:00:00 2001 From: Reid Levesque Date: Wed, 31 Jul 2024 11:05:45 -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()) }