[release] version 0.5.0-unstable24
This commit is contained in:
parent
aa0a4f8865
commit
7134301f64
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "cosmos-server",
|
||||
"version": "0.5.0-unstable23",
|
||||
"version": "0.5.0-unstable24",
|
||||
"description": "",
|
||||
"main": "test-server.js",
|
||||
"bugs": {
|
||||
|
|
32
src/icons.go
32
src/icons.go
|
@ -81,28 +81,38 @@ func GetFavicon(w http.ResponseWriter, req *http.Request) {
|
|||
}
|
||||
|
||||
var icons []*favicon.Icon
|
||||
var defaultIcons = []*favicon.Icon{
|
||||
&favicon.Icon{URL: "favicon.png", Width: 0},
|
||||
&favicon.Icon{URL: "/favicon.png", Width: 0},
|
||||
&favicon.Icon{URL: "favicon.ico", Width: 0},
|
||||
&favicon.Icon{URL: "/favicon.ico", Width: 0},
|
||||
}
|
||||
|
||||
// follow siteurl and check if any redirect.
|
||||
respNew, err := http.Get(siteurl)
|
||||
|
||||
if err != nil {
|
||||
utils.Error("FaviconFetch", err)
|
||||
icons = []*favicon.Icon{
|
||||
&favicon.Icon{URL: "favicon.png", Width: 0},
|
||||
&favicon.Icon{URL: "/favicon.png", Width: 0},
|
||||
&favicon.Icon{URL: "favicon.ico", Width: 0},
|
||||
&favicon.Icon{URL: "/favicon.ico", Width: 0},
|
||||
}
|
||||
icons = append(icons, defaultIcons...)
|
||||
} else {
|
||||
siteurl = respNew.Request.URL.String()
|
||||
icons, err = favicon.Find(siteurl)
|
||||
|
||||
if err != nil || len(icons) == 0 {
|
||||
icons = []*favicon.Icon{
|
||||
&favicon.Icon{URL: "favicon.png", Width: 0},
|
||||
&favicon.Icon{URL: "/favicon.png", Width: 0},
|
||||
&favicon.Icon{URL: "favicon.ico", Width: 0},
|
||||
&favicon.Icon{URL: "/favicon.ico", Width: 0},
|
||||
icons = append(icons, defaultIcons...)
|
||||
} else {
|
||||
// Check if icons list is missing any default values
|
||||
for _, defaultIcon := range defaultIcons {
|
||||
found := false
|
||||
for _, icon := range icons {
|
||||
if icon.URL == defaultIcon.URL {
|
||||
found = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !found {
|
||||
icons = append(icons, defaultIcon)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue