Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/soft-meals-invite.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"thirdweb": patch
---

fix ipfs `resolveScheme` bug for v1 ipfs schemes
12 changes: 12 additions & 0 deletions packages/thirdweb/src/utils/ipfs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,18 @@ describe("resolveScheme", () => {
expect(url).toMatchInlineSnapshot(`"https://test.ipfscdn.io/ipfs/Qm..."`);
});

it("should resolve ipfs scheme", () => {
const client = createThirdwebClient({
clientId: "test",
});
const uri =
"ipfs://bafkreidi5y7afj5z4xrz7uz5rkg2mcsv2p2n4ui4g7q4k4ecdz65i2agou";
const url = resolveScheme({ client, uri });
expect(url).toMatchInlineSnapshot(
`"https://test.ipfscdn.io/ipfs/bafkreidi5y7afj5z4xrz7uz5rkg2mcsv2p2n4ui4g7q4k4ecdz65i2agou"`,
);
});

it("should resolve ipfs scheme when passing a gateway override", () => {
const client = createThirdwebClient({
clientId: "test",
Expand Down
2 changes: 1 addition & 1 deletion packages/thirdweb/src/utils/ipfs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export function findIPFSCidFromUri(uri: string) {
}

// first index of `/Qm` or `/bafy` in the uri (case insensitive)
const firstIndex = uri.search(/\/(Qm|bafy)/i);
const firstIndex = uri.search(/\/(Qm|baf)/i);
// we start one character after the first `/` to avoid including it in the CID
return uri.slice(firstIndex + 1);
}
Expand Down