Skip to content

Commit

Permalink
Handle empty path
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoPolo committed Aug 19, 2023
1 parent f503703 commit 128cc0f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion p2p/http/libp2phttp.go
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ func (h *HTTPHost) SetHTTPHandler(p protocol.ID, handler http.Handler) {
// http.StripPrefix is called on the handler, so the handler will be unaware of
// it's prefix path.
func (h *HTTPHost) SetHTTPHandlerAtPath(p protocol.ID, path string, handler http.Handler) {
if path[len(path)-1] != '/' {
if path == "" || path[len(path)-1] != '/' {
// We are nesting this handler under this path, so it should end with a slash.
path += "/"
}
Expand Down

0 comments on commit 128cc0f

Please sign in to comment.