engine: resources: Avoid double slash on error

Errors will include a second slash if this ends with one. Might as well
clean it to avoid the semblance of a bug.
This commit is contained in:
James Shubin
2025-05-09 00:00:46 -04:00
parent 9a63fadfbd
commit e86d66b906

View File

@@ -1815,8 +1815,8 @@ func ReadDir(p string) ([]FileInfo, error) {
if !strings.HasSuffix(p, "/") { // dirs have trailing slashes if !strings.HasSuffix(p, "/") { // dirs have trailing slashes
return nil, fmt.Errorf("path must be a directory") return nil, fmt.Errorf("path must be a directory")
} }
output := []FileInfo{} // my file info output := []FileInfo{} // my file info
files, err := os.ReadDir(p) files, err := os.ReadDir(path.Clean(p)) // clean for prettier errors
if os.IsNotExist(err) { if os.IsNotExist(err) {
return output, err // return empty list return output, err // return empty list
} }