Skip to content

Commit a5e27be

Browse files
committed
chore: defer to go-trustless-utils for filename check
1 parent 55da90b commit a5e27be

File tree

3 files changed

+7
-17
lines changed

3 files changed

+7
-17
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ require (
1616
github.com/ipld/go-codec-dagpb v1.7.0
1717
github.com/ipld/go-fixtureplate v0.1.0
1818
github.com/ipld/go-ipld-prime v0.21.0
19-
github.com/ipld/go-trustless-utils v0.6.0
19+
github.com/ipld/go-trustless-utils v0.6.1-0.20251014050816-171c6b23a8c1
2020
github.com/ipld/ipld/specs v0.0.0-20231012031213-54d3b21deda4
2121
github.com/ipni/go-libipni v0.7.1
2222
github.com/ipni/index-provider v0.15.5

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,8 @@ github.com/ipld/go-ipld-prime v0.21.0 h1:n4JmcpOlPDIxBcY037SVfpd1G+Sj1nKZah0m6QH
210210
github.com/ipld/go-ipld-prime v0.21.0/go.mod h1:3RLqy//ERg/y5oShXXdx5YIp50cFGOanyMctpPjsvxQ=
211211
github.com/ipld/go-ipld-prime/storage/bsadapter v0.0.0-20250821084354-a425e60cd714 h1:cqNk8PEwHnK0vqWln+U/YZhQc9h2NB3KjUjDPZo5Q2s=
212212
github.com/ipld/go-ipld-prime/storage/bsadapter v0.0.0-20250821084354-a425e60cd714/go.mod h1:ZEUdra3CoqRVRYgAX/jAJO9aZGz6SKtKEG628fHHktY=
213-
github.com/ipld/go-trustless-utils v0.6.0 h1:Yy9L+HI2AQwlq5EQPr3ZyAKbkBz/BpojqGAvym0s2lA=
214-
github.com/ipld/go-trustless-utils v0.6.0/go.mod h1:inKRRT3L9BT1r/u6yBbXuIq+wIGO2yf0NqiOo36bH9U=
213+
github.com/ipld/go-trustless-utils v0.6.1-0.20251014050816-171c6b23a8c1 h1:LGTUHNsKLlL2zzXlJL5KZnvteRhQblhOP8CBKaUZi7M=
214+
github.com/ipld/go-trustless-utils v0.6.1-0.20251014050816-171c6b23a8c1/go.mod h1:inKRRT3L9BT1r/u6yBbXuIq+wIGO2yf0NqiOo36bH9U=
215215
github.com/ipld/ipld/specs v0.0.0-20231012031213-54d3b21deda4 h1:0VXv637/xpI0Pb5J8K+K8iRtTw4DOcxs0MB1HMzfwNY=
216216
github.com/ipld/ipld/specs v0.0.0-20231012031213-54d3b21deda4/go.mod h1:WcT0DfRe+e2QFY0kcbsOnuT6jL5Q0JNZ83I5DHIdStg=
217217
github.com/ipni/go-libipni v0.7.1 h1:0peyJTXXgrDHqjiqpSuYlxH3JIvnUMw1Orq7nJtq/tY=

httpipfs.go

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -255,21 +255,11 @@ func NewHttpIpfsHandlerFunc(
255255
}
256256
accept := accepts[0]
257257

258-
// Parse filename parameter - trustlesshttp.ParseFilename only accepts .car
259-
// but frisbii also supports raw responses with .bin, so we handle that case
260-
fileName, err := trustlesshttp.ParseFilename(req)
258+
// Parse filename parameter - supports both .car and .bin extensions
259+
fileName, err := trustlesshttp.ParseFilename(req, accepts)
261260
if err != nil {
262-
// If ParseFilename failed, check if it's because of .bin extension for raw response
263-
if accept.IsRaw() && req.URL.Query().Get("filename") != "" {
264-
fileName = req.URL.Query().Get("filename")
265-
if !strings.HasSuffix(fileName, ".bin") {
266-
logError(http.StatusBadRequest, fmt.Errorf("invalid filename parameter for raw response; expected .bin extension"))
267-
return
268-
}
269-
} else {
270-
logError(http.StatusBadRequest, err)
271-
return
272-
}
261+
logError(http.StatusBadRequest, err)
262+
return
273263
}
274264

275265
// validate CID path parameter

0 commit comments

Comments
 (0)