Fix for Errors/404s with no path.
This commit is contained in:
parent
66de98358b
commit
a16e640799
1 changed files with 6 additions and 4 deletions
10
main.go
10
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)
|
||||
|
|
Loading…
Add table
Reference in a new issue