How are base64 encoded CIDs handled when they have / in them?

I’m trying to generate an example to test in a gateway, if I run:

echo `date` | ipfs add -q --cid-version 1 | ipfs cid format -b base64pad

If the CID does not have a / in, then I can fetch it.

❯ ipfs cat MAVUSIBgw3w0bif+fxNjud71nu7jhxJACQ46wOa9F9W6xTvgd
Sun 6 Mar 00:39:19 GMT 2022

But if it does, I cant

❯ echo `date` | ipfs add -q --cid-version 1 | ipfs cid format -b base64pad

❯ ipfs cat MAVUSIMIR0/9W0S1NQUA34C+Es1Qmq1OFmh0xO5iZpGBwwP/7
Error: invalid path "MAVUSIMIR0/9W0S1NQUA34C+Es1Qmq1OFmh0xO5iZpGBwwP/7": illegal base64 data at input byte 8

What do I have to do? How can I hit this CID from a gateway?

I don’t belive anyone actually use base64.
We use base64url when we want compacter CIDs (it use _ instead).
You can use ipfs cid format -v 1 -b base64url MAVUSIMIR0/9W0S1NQUA34C+Es1Qmq1OFmh0xO5iZpGBwwP/7 to convert them.

1 Like

You beat me to it. I was going to suggest base64url for the very reason that it doesn’t have a forward slash in it. More info can be found here: Base64 - Wikipedia

I have opened an issue CIDs containing "/" cannot be parsed · Issue #54 · ipfs/go-path · GitHub.

1 Like