diff --git a/CHANGELOG.md b/CHANGELOG.md index 6d41b572..66fd622c 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/build/VERSION b/build/VERSION index cc868b62..4bac418e 100755 --- a/build/VERSION +++ b/build/VERSION @@ -1 +1 @@ -4.0.1 \ No newline at end of file +4.0.2 \ No newline at end of file diff --git a/build/main.go b/build/main.go index 8c32ae1a..87ccb1b4 100755 --- a/build/main.go +++ b/build/main.go @@ -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!") -} +} \ No newline at end of file