Skip to content

Commit

Permalink
fix: no //index.html
Browse files Browse the repository at this point in the history
  • Loading branch information
aschmahmann committed Aug 10, 2023
1 parent 3b83506 commit 0871b7f
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions gateway/handler_unixfs_dir.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,16 @@ func (i *handler) serveDirectory(ctx context.Context, w http.ResponseWriter, r *
}

// Check if directory has index.html, if so, serveFile
idxPath := ipath.Join(contentPath, "index.html")
imIndexPath, err := NewImmutablePath(ipath.Join(resolvedPath, "index.html"))
appendIndexHtml := func(p ipath.Path) ipath.Path {
basePath := p.String()
if basePath[len(basePath)-1] == '/' {
return ipath.New(basePath + "index.html")
}
return ipath.New(basePath + "/index.html")
}

idxPath := appendIndexHtml(contentPath)
imIndexPath, err := NewImmutablePath(appendIndexHtml(resolvedPath))
if err != nil {
i.webError(w, r, err, http.StatusInternalServerError)
return false
Expand Down

0 comments on commit 0871b7f

Please sign in to comment.