Fix so that ending slash doesn't matter for characters path
All checks were successful
Build / build (push) Successful in 40s

This commit is contained in:
2025-11-08 12:04:44 +01:00
parent c369b13fae
commit aa0b8275e7

View File

@@ -1,6 +1,7 @@
package backend
import (
"fmt"
"log"
"os"
"strings"
@@ -8,6 +9,10 @@ import (
func GetCharacterList() []string {
charactersPath := os.Getenv("CHARACTERS_PATH")
fmt.Printf("dir: %s\n", charactersPath)
if !strings.HasSuffix(charactersPath, "/") {
charactersPath += "/"
}
files, err := os.ReadDir(charactersPath)
if err != nil {
log.Fatal(err)
@@ -24,7 +29,11 @@ func GetCharacterList() []string {
func GetCharacter(character string) string {
charactersPath := os.Getenv("CHARACTERS_PATH")
return charactersPath + "/" + character
fmt.Printf("dir: %s\n", charactersPath)
if !strings.HasSuffix(charactersPath, "/") {
charactersPath += "/"
}
return charactersPath + character
}
func isImage(entry os.DirEntry) bool {