Skip to content

Commit cd67d2d

Browse files
hacdiaslidel
authored andcommitted
fix(gateway): allow CAR trustless requests with path
1 parent abc4d0c commit cd67d2d

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

gateway/gateway_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -676,8 +676,9 @@ func TestIpfsTrustlessMode(t *testing.T) {
676676
trustlessTests := func(t *testing.T, host string) {
677677
doIpfsCidRequests(t, trustlessFormats, host, http.StatusOK)
678678
doIpfsCidRequests(t, trustedFormats, host, http.StatusNotAcceptable)
679-
doIpfsCidPathRequests(t, trustlessFormats, host, http.StatusNotAcceptable)
680679
doIpfsCidPathRequests(t, trustedFormats, host, http.StatusNotAcceptable)
680+
doIpfsCidPathRequests(t, []string{"raw"}, host, http.StatusNotAcceptable)
681+
doIpfsCidPathRequests(t, []string{"car"}, host, http.StatusOK)
681682
}
682683

683684
t.Run("Explicit Trustless Gateway", func(t *testing.T) {

gateway/handler.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ func (i *handler) isTrustlessRequest(contentPath ipath.Path, responseFormat stri
331331
// Only allow "/{#1}/{#2}"-like paths.
332332
trimmedPath := strings.Trim(contentPath.String(), "/")
333333
pathComponents := strings.Split(trimmedPath, "/")
334-
if len(pathComponents) != 2 {
334+
if responseFormat != carResponseFormat && len(pathComponents) != 2 {
335335
return false
336336
}
337337

0 commit comments

Comments
 (0)