RangerMauve / js-ipfs-fetch

Use the same `fetch()` API browsers provide for HTTP, but for IPFS
https://youtu.be/kI9Issf3MNc?t=1606
MIT License
65 stars 8 forks source link

Error with IPNS paths with ending slash #4

Open lumenpink opened 3 years ago

lumenpink commented 3 years ago

Hi!

I found a little Bug in this implementation when the URL have a trailing slash

The script enters in this IF and treats the answer like a directory and not a file. I tested locking it as always false and it runs OK.

https://github.com/RangerMauve/js-ipfs-fetch/blob/631127a8568aecab8f497c4cf6149162b87ebf8f/index.js#L129

RangerMauve commented 3 years ago

The trailing slash usually means that it's a directory. 🤔 From there it will look for an index.html or similar to resolve to a file if it exists.

Could you point to an example URL with the trailing slash as well as which software it works in?

RangerMauve commented 3 years ago

Here's an example URL which this happens with: ipfs://bafybeigdyrzt5sfp7udm7hu76uh7y26nf3efuylqabf3oclgtqy55fbzdi/

This is gonna be a bit hard because ipfs-fetch doesn't have a way to understand the mime type without a file extension at the moment. 🤔