Skip to content

Commit

Permalink
fix(gateway): allow CAR trustless requests with path
Browse files Browse the repository at this point in the history
  • Loading branch information
hacdias committed Jun 19, 2023
1 parent abc4d0c commit 4530557
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion gateway/gateway_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -676,8 +676,9 @@ func TestIpfsTrustlessMode(t *testing.T) {
trustlessTests := func(t *testing.T, host string) {
doIpfsCidRequests(t, trustlessFormats, host, http.StatusOK)
doIpfsCidRequests(t, trustedFormats, host, http.StatusNotAcceptable)
doIpfsCidPathRequests(t, trustlessFormats, host, http.StatusNotAcceptable)
doIpfsCidPathRequests(t, trustedFormats, host, http.StatusNotAcceptable)
doIpfsCidPathRequests(t, []string{"raw"}, host, http.StatusNotAcceptable)
doIpfsCidPathRequests(t, []string{"car"}, host, http.StatusOK)
}

t.Run("Explicit Trustless Gateway", func(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion gateway/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ func (i *handler) isTrustlessRequest(contentPath ipath.Path, responseFormat stri
// Only allow "/{#1}/{#2}"-like paths.
trimmedPath := strings.Trim(contentPath.String(), "/")
pathComponents := strings.Split(trimmedPath, "/")
if len(pathComponents) != 2 {
if responseFormat != carResponseFormat && len(pathComponents) != 2 {
return false
}

Expand Down

0 comments on commit 4530557

Please sign in to comment.