Skip to content

Commit

Permalink
update rig image urls to use cid subdomain urls
Browse files Browse the repository at this point in the history
  • Loading branch information
datadanne committed Aug 10, 2023
1 parent 0ca0079 commit df62228
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions garage/src/hooks/useRigImageUrls.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { Rig } from "../types";

const ipfsGatewayBaseUrl = "https://nftstorage.link";

const ipfsUriToGatewayUrl = (ipfsUri: string): string => {
const cidAndPath = ipfsUri.match(/^ipfs:\/\/(.*)$/)![1];
return `${ipfsGatewayBaseUrl}/ipfs/${cidAndPath}`;
const match = ipfsUri.match(/^ipfs:\/\/([a-zA-Z0-9]*)\/(.*)$/);
if (!match) return "";

const [, cid, path] = match;
return `https://${cid}.ipfs.nftstorage.link/${path}`;
};

interface RigImageUrls {
Expand Down

0 comments on commit df62228

Please sign in to comment.