Fix bug when dealing with encoded paths.

This commit is contained in:
FireMasterK 2021-06-10 01:52:02 +05:30
parent 2d96fc49a1
commit 66de98358b
No known key found for this signature in database
GPG Key ID: 8DFF5DD33E93DB58
1 changed files with 4 additions and 4 deletions

View File

@ -55,7 +55,7 @@ func (*requesthandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
} }
if len(host) <= 0 { if len(host) <= 0 {
host = getHost(req.URL.Path) host = getHost(req.URL.RawPath)
} }
if len(host) <= 0 { if len(host) <= 0 {
@ -63,7 +63,7 @@ func (*requesthandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
return return
} }
path := req.URL.Path path := req.URL.RawPath
path = strings.Replace(path, "/ggpht", "", 1) path = strings.Replace(path, "/ggpht", "", 1)
path = strings.Replace(path, "/i/", "/", 1) path = strings.Replace(path, "/i/", "/", 1)
@ -76,8 +76,8 @@ func (*requesthandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
proxyURL.RawQuery = q.Encode() proxyURL.RawQuery = q.Encode()
if strings.HasSuffix(proxyURL.Path, "maxres.jpg") { if strings.HasSuffix(proxyURL.RawPath, "maxres.jpg") {
proxyURL.Path = getBestThumbnail(proxyURL.Path) proxyURL.RawPath = getBestThumbnail(proxyURL.RawPath)
} }
request, err := http.NewRequest("GET", proxyURL.String(), nil) request, err := http.NewRequest("GET", proxyURL.String(), nil)