From a16e640799e8f439f5324f401072daa2b6db4047 Mon Sep 17 00:00:00 2001 From: FireMasterK <20838718+FireMasterK@users.noreply.github.com> Date: Thu, 10 Jun 2021 02:41:57 +0530 Subject: [PATCH] Fix for Errors/404s with no path. --- main.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/main.go b/main.go index fd10771..67d6482 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.RawPath) + host = getHost(req.URL.EscapedPath()) } if len(host) <= 0 { @@ -63,7 +63,7 @@ func (*requesthandler) ServeHTTP(w http.ResponseWriter, req *http.Request) { return } - path := req.URL.RawPath + path := req.URL.EscapedPath() path = strings.Replace(path, "/ggpht", "", 1) path = strings.Replace(path, "/i/", "/", 1) @@ -76,10 +76,12 @@ func (*requesthandler) ServeHTTP(w http.ResponseWriter, req *http.Request) { proxyURL.RawQuery = q.Encode() - if strings.HasSuffix(proxyURL.RawPath, "maxres.jpg") { - proxyURL.RawPath = getBestThumbnail(proxyURL.RawPath) + if strings.HasSuffix(proxyURL.EscapedPath(), "maxres.jpg") { + proxyURL.RawPath = getBestThumbnail(proxyURL.EscapedPath()) } + fmt.Println(proxyURL.String()) + request, err := http.NewRequest("GET", proxyURL.String(), nil) copyHeaders(req.Header, request.Header)