From 66de98358be5c1df62f131b7a1c5f3305d822ef6 Mon Sep 17 00:00:00 2001 From: FireMasterK <20838718+FireMasterK@users.noreply.github.com> Date: Thu, 10 Jun 2021 01:52:02 +0530 Subject: [PATCH] Fix bug when dealing with encoded paths. --- main.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/main.go b/main.go index 56adc86..fd10771 100644 --- a/main.go +++ b/main.go @@ -55,7 +55,7 @@ func (*requesthandler) ServeHTTP(w http.ResponseWriter, req *http.Request) { } if len(host) <= 0 { - host = getHost(req.URL.Path) + host = getHost(req.URL.RawPath) } if len(host) <= 0 { @@ -63,7 +63,7 @@ func (*requesthandler) ServeHTTP(w http.ResponseWriter, req *http.Request) { return } - path := req.URL.Path + path := req.URL.RawPath path = strings.Replace(path, "/ggpht", "", 1) path = strings.Replace(path, "/i/", "/", 1) @@ -76,8 +76,8 @@ func (*requesthandler) ServeHTTP(w http.ResponseWriter, req *http.Request) { proxyURL.RawQuery = q.Encode() - if strings.HasSuffix(proxyURL.Path, "maxres.jpg") { - proxyURL.Path = getBestThumbnail(proxyURL.Path) + if strings.HasSuffix(proxyURL.RawPath, "maxres.jpg") { + proxyURL.RawPath = getBestThumbnail(proxyURL.RawPath) } request, err := http.NewRequest("GET", proxyURL.String(), nil)