mirror of
https://github.com/yusing/godoxy.git
synced 2025-05-20 12:42:34 +02:00
fix favicon redirection path
This commit is contained in:
parent
fcbb51dce7
commit
645a58464c
1 changed files with 6 additions and 0 deletions
|
@ -9,6 +9,7 @@ import (
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
"path"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
@ -157,6 +158,7 @@ func sanitizeName(name string) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func findIcon(r route.HTTPRoute, req *http.Request, uri string) (icon []byte, status int, errMsg string) {
|
func findIcon(r route.HTTPRoute, req *http.Request, uri string) (icon []byte, status int, errMsg string) {
|
||||||
|
// FIXME: invalidate cache on route change
|
||||||
key := r.TargetName()
|
key := r.TargetName()
|
||||||
icon, ok := loadIconCache(key)
|
icon, ok := loadIconCache(key)
|
||||||
if ok {
|
if ok {
|
||||||
|
@ -201,6 +203,10 @@ func findIconSlow(r route.HTTPRoute, req *http.Request, uri string) (icon []byte
|
||||||
return nil, http.StatusBadGateway, "connection error"
|
return nil, http.StatusBadGateway, "connection error"
|
||||||
default:
|
default:
|
||||||
if loc := c.Header().Get("Location"); loc != "" {
|
if loc := c.Header().Get("Location"); loc != "" {
|
||||||
|
loc = path.Clean(loc)
|
||||||
|
if !strings.HasPrefix(loc, "/") {
|
||||||
|
loc = "/" + loc
|
||||||
|
}
|
||||||
if loc == newReq.URL.Path {
|
if loc == newReq.URL.Path {
|
||||||
return nil, http.StatusBadGateway, "circular redirect"
|
return nil, http.StatusBadGateway, "circular redirect"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue