fix(storage): return empty array instead of null for file list
Initialize files slice with make() to ensure JSON serialization returns [] instead of null when no files exist. Prevents frontend TypeError when calling .map() on null.
This commit is contained in:
@@ -52,7 +52,7 @@ func (s *Storage) List() ([]string, error) {
|
||||
return nil, fmt.Errorf("failed to read data directory: %w", err)
|
||||
}
|
||||
|
||||
var files []string
|
||||
files := make([]string, 0)
|
||||
for _, entry := range entries {
|
||||
if !entry.IsDir() && strings.HasSuffix(entry.Name(), ".md") {
|
||||
files = append(files, strings.TrimSuffix(entry.Name(), ".md"))
|
||||
|
||||
Reference in New Issue
Block a user