Fix for Errors/404s with no path.

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

10
main.go
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.RawPath) host = getHost(req.URL.EscapedPath())
} }
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.RawPath path := req.URL.EscapedPath()
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,10 +76,12 @@ func (*requesthandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
proxyURL.RawQuery = q.Encode() proxyURL.RawQuery = q.Encode()
if strings.HasSuffix(proxyURL.RawPath, "maxres.jpg") { if strings.HasSuffix(proxyURL.EscapedPath(), "maxres.jpg") {
proxyURL.RawPath = getBestThumbnail(proxyURL.RawPath) proxyURL.RawPath = getBestThumbnail(proxyURL.EscapedPath())
} }
fmt.Println(proxyURL.String())
request, err := http.NewRequest("GET", proxyURL.String(), nil) request, err := http.NewRequest("GET", proxyURL.String(), nil)
copyHeaders(req.Header, request.Header) copyHeaders(req.Header, request.Header)