ipfs / helia-verified-fetch

A fetch-like API for obtaining verified & trustless IPFS CIDs on the web
https://npmjs.com/package/@helia/verified-fetch
Other
19 stars 5 forks source link

fix: implicit accept header can be overridden by format query #36

Closed SgtPooki closed 7 months ago

SgtPooki commented 7 months ago

Title

fix: implicit accept header can be overridden by format query

Description

Fixes https://github.com/ipfs/helia-verified-fetch/issues/35 & also allows mapping of 'raw' to 'dag-json'. I imagine users will get errors if they try to accept dag-json for non-json content, we can address that later?

Notes & open questions

Basically, we were previously doing the following:

  1. check accept header
  2. check format query param
  3. if accept header exists, use it, otherwise, use the mapped query param format

However, that was causing the bug in https://github.com/ipfs/helia-verified-fetch/issues/35 because the format query param was being ignored if the accept header was present (which it usually is for most clients), even if it wasn't a valid IPFS gateway Accept header

Now, we do this:

  1. check accept header
  2. check format query param
  3. if accept header is not a valid IPFS gateway accept header, and we have a mapping for the format query param, use the mapped query param format value.
  4. otherwise use the accept header

more notes are in https://github.com/ipfs/helia-verified-fetch/issues/35

Change checklist

github-actions[bot] commented 7 months ago

:tada: This PR is included in version 1.3.6 :tada:

The release is available on npm package (@latest dist-tag)

Your semantic-release bot :package::rocket:

github-actions[bot] commented 7 months ago

:tada: This PR is included in version 1.14.0 :tada:

The release is available on npm package (@latest dist-tag)

Your semantic-release bot :package::rocket:

github-actions[bot] commented 6 months ago

:tada: This PR is included in version 1.0.0 :tada:

The release is available on npm package (@latest dist-tag)

Your semantic-release bot :package::rocket:

github-actions[bot] commented 1 month ago

:tada: This PR is included in version 1.0.0 :tada:

The release is available on GitHub release

Your semantic-release bot :package::rocket: