Remove unnecessary check for leading slash in JSON dump

This commit is contained in:
Seednode 2024-02-06 15:41:34 -06:00
parent ca8818af78
commit 158d304bee
2 changed files with 7 additions and 11 deletions

View File

@ -28,32 +28,28 @@ type fileIndex struct {
func makeTree(list []string) ([]byte, error) { func makeTree(list []string) ([]byte, error) {
tree := make(map[string]any) tree := make(map[string]any)
cur := tree current := tree
for _, entry := range list { for _, entry := range list {
if len(entry) > 0 && entry[0] == '/' {
entry = entry[1:]
}
path := strings.Split(entry, string(os.PathSeparator)) path := strings.Split(entry, string(os.PathSeparator))
for i, last := 0, len(path)-1; i < len(path); i++ { for i, last := 0, len(path)-1; i < len(path); i++ {
if i == last { if i == last {
cur[path[i]] = nil current[path[i]] = nil
break break
} }
v, ok := cur[path[i]].(map[string]any) v, ok := current[path[i]].(map[string]any)
if !ok || v == nil { if !ok || v == nil {
v = make(map[string]any) v = make(map[string]any)
cur[path[i]] = v current[path[i]] = v
} }
cur = v current = v
} }
cur = tree current = tree
} }
resp, err := json.MarshalIndent(tree, "", " ") resp, err := json.MarshalIndent(tree, "", " ")

View File

@ -17,7 +17,7 @@ import (
const ( const (
AllowedCharacters string = `^[A-z0-9.\-_]+$` AllowedCharacters string = `^[A-z0-9.\-_]+$`
ReleaseVersion string = "8.5.0" ReleaseVersion string = "8.5.1"
) )
var ( var (