[release] version 0.5.0-unstable24
This commit is contained in:
parent
aa0a4f8865
commit
7134301f64
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "cosmos-server",
|
"name": "cosmos-server",
|
||||||
"version": "0.5.0-unstable23",
|
"version": "0.5.0-unstable24",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "test-server.js",
|
"main": "test-server.js",
|
||||||
"bugs": {
|
"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 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.
|
// follow siteurl and check if any redirect.
|
||||||
respNew, err := http.Get(siteurl)
|
respNew, err := http.Get(siteurl)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
utils.Error("FaviconFetch", err)
|
utils.Error("FaviconFetch", err)
|
||||||
icons = []*favicon.Icon{
|
icons = append(icons, defaultIcons...)
|
||||||
&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},
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
siteurl = respNew.Request.URL.String()
|
siteurl = respNew.Request.URL.String()
|
||||||
icons, err = favicon.Find(siteurl)
|
icons, err = favicon.Find(siteurl)
|
||||||
|
|
||||||
if err != nil || len(icons) == 0 {
|
if err != nil || len(icons) == 0 {
|
||||||
icons = []*favicon.Icon{
|
icons = append(icons, defaultIcons...)
|
||||||
&favicon.Icon{URL: "favicon.png", Width: 0},
|
} else {
|
||||||
&favicon.Icon{URL: "/favicon.png", Width: 0},
|
// Check if icons list is missing any default values
|
||||||
&favicon.Icon{URL: "favicon.ico", Width: 0},
|
for _, defaultIcon := range defaultIcons {
|
||||||
&favicon.Icon{URL: "/favicon.ico", Width: 0},
|
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