From f44b9267ad6cdfe507ede7507670552b6bff8fa4 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Wed, 25 Sep 2024 09:47:51 -0500 Subject: [PATCH] Remove unused utils/ipfs.ts --- src/utils/ipfs.ts | 27 --------------------------- 1 file changed, 27 deletions(-) delete mode 100644 src/utils/ipfs.ts diff --git a/src/utils/ipfs.ts b/src/utils/ipfs.ts deleted file mode 100644 index b4f94443..00000000 --- a/src/utils/ipfs.ts +++ /dev/null @@ -1,27 +0,0 @@ -/** https://docs.ipfs.tech/how-to/address-ipfs-on-web/#path-gateway */ -const IPFS_PATH_REGEX = /^\/ipfs\/([^/]+)/; -/** https://docs.ipfs.tech/how-to/address-ipfs-on-web/#subdomain-gateway */ -const IPFS_HOST_REGEX = /^([^/]+)\.ipfs\./; - -/** Get IPFS CID out of a path. */ -function cidFromPath(path: string) { - return path.match(IPFS_PATH_REGEX)?.[1]; -} - -/** Get IPFS CID out of a host. */ -function cidFromHost(host: string) { - return host.match(IPFS_HOST_REGEX)?.[1]; -} - -/** Get IPFS CID out of a URL. */ -function cidFromUrl({ protocol, hostname, pathname }: URL) { - switch (protocol) { - case 'ipfs:': - return hostname; - case 'http:': - case 'https:': - return cidFromPath(pathname) || cidFromHost(hostname); - } -} - -export { cidFromUrl };