mirror of
https://github.com/selfhst/icons.git
synced 2026-04-30 13:26:18 -04:00
v4.0.2 (Custom icon fix, root path info)
This commit is contained in:
@@ -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
|
# v4.0.1
|
||||||
|
|
||||||
## What's Changed
|
## What's Changed
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
4.0.1
|
4.0.2
|
||||||
@@ -558,7 +558,17 @@ func handleCustomIcon(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
filename = strings.ToLower(filename)
|
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)
|
stat, err := os.Stat(customPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -633,6 +643,15 @@ func main() {
|
|||||||
|
|
||||||
mux := http.NewServeMux()
|
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) {
|
mux.HandleFunc("GET /health", func(w http.ResponseWriter, r *http.Request) {
|
||||||
w.WriteHeader(http.StatusOK)
|
w.WriteHeader(http.StatusOK)
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user