v4.0.2 (Custom icon fix, root path info)

This commit is contained in:
selfhst-bot
2026-03-10 05:37:12 -04:00
parent 610c44c64c
commit a6013bfefe
3 changed files with 29 additions and 3 deletions

View File

@@ -1,3 +1,10 @@
# v4.0.2
## What's Changed
* Fixed custom icon issue where names converted to lowercase for cache keys were also being used to look up the file path, causing requests for icons with uppercase characters to fail ([#751](https://github.com/selfhst/icons/issues/751))
* Added server name and sample endpoints to the root path ([#752](https://github.com/selfhst/icons/issues/752))
# v4.0.1
## What's Changed

View File

@@ -1 +1 @@
4.0.1
4.0.2

View File

@@ -558,7 +558,17 @@ func handleCustomIcon(w http.ResponseWriter, r *http.Request) {
filename = strings.ToLower(filename)
customPath := filepath.Join(config.LocalPath, "custom", filename)
actualFilename := filename
if entries, err := os.ReadDir(filepath.Join(config.LocalPath, "custom")); err == nil {
for _, entry := range entries {
if strings.ToLower(entry.Name()) == filename {
actualFilename = entry.Name()
break
}
}
}
customPath := filepath.Join(config.LocalPath, "custom", actualFilename)
stat, err := os.Stat(customPath)
if err != nil {
@@ -633,6 +643,15 @@ func main() {
mux := http.NewServeMux()
mux.HandleFunc("GET /", func(w http.ResponseWriter, r *http.Request) {
if r.URL.Path != "/" {
http.NotFound(w, r)
return
}
w.Header().Set("Content-Type", "text/plain; charset=utf-8")
fmt.Fprintf(w, "selfh.st/icons\n\nEndpoints:\n GET /{iconname}\n GET /{iconname}/{colorcode}\n GET /custom/{filename}\n GET /health\n")
})
mux.HandleFunc("GET /health", func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)
})
@@ -704,4 +723,4 @@ func main() {
}
log.Println("Server stopped. Bye for now!")
}
}