From df72b6edc5ad62a8e1ab6186c9c1e87794e5445e Mon Sep 17 00:00:00 2001 From: Tom McKeesick Date: Thu, 6 Apr 2023 00:53:33 +1000 Subject: [PATCH] Remove null category when generating trim the slash from paths like /gen8/shiny/froakie.cow, to ensure that there is no empty category in first position --- src/pokedex/pokedex.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/pokedex/pokedex.go b/src/pokedex/pokedex.go index ea7a5060..785d49ed 100644 --- a/src/pokedex/pokedex.go +++ b/src/pokedex/pokedex.go @@ -160,8 +160,13 @@ func CreateCategoryStruct(rootDir string, metadata []PokemonMetadata, debug bool "build/assets/categories/%s", cat, ) + fpath := fmt.Sprintf("%s/%02d%s", destDir, i, ".cat") os.MkdirAll(destDir, 0755) - WriteBytesToFile([]byte(fmt.Sprintf("%d/%d", i, j)), fmt.Sprintf("%s/%02d%s", destDir, i, ".cat"), false) + WriteBytesToFile( + []byte(fmt.Sprintf("%d/%d", i, j)), + fpath, + false, + ) } } } @@ -169,7 +174,7 @@ func CreateCategoryStruct(rootDir string, metadata []PokemonMetadata, debug bool } func createCategories(fpath string, data []byte) []string { - parts := strings.Split(fpath, "/") + parts := strings.Split(strings.TrimLeft(fpath, "/"), "/") height := sizeCategory(len(strings.Split(string(data), "\n"))) return append([]string{height}, parts[0:len(parts)-1]...)