🐛 Fix serve static dir issue

This commit is contained in:
LittleSheep 2024-10-11 00:58:59 +08:00
parent a11af366ef
commit b006d29f53

View File

@ -148,10 +148,10 @@ func makeFileResponse(c *fiber.Ctx, dest *Destination) error {
return fmt.Errorf("failed to stat: %w", err)
}
// Serve index if path is directory
// Serve index if the path is a directory
if stat.IsDir() {
indexFile := lo.Ternary(len(queries.Get("index")) > 0, queries.Get("index"), "index.html")
indexPath := utils.TrimRight(path, '/') + indexFile
indexPath := filepath.Join(path, indexFile)
index, err := root.Open(indexPath)
if err == nil {
indexStat, err := index.Stat()