Skip to content

Commit

Permalink
Consolidate fetching logic
Browse files Browse the repository at this point in the history
  • Loading branch information
pgebheim committed Nov 3, 2020
1 parent dff20fd commit 7a433ef
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 7 deletions.
7 changes: 1 addition & 6 deletions packages/augur-sdk/src/warp/WarpController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -303,13 +303,8 @@ export class WarpController {
let fileResult;
switch (this.ipfsEndpointInfo.version) {
case IPFSHashVersion.CIDv0:
fileResult = await fetch(`${this.ipfsEndpointInfo.url}/ipfs/${ipfsHash}${ipfsPath}`)
.then(item => item.arrayBuffer())
.then(item => new Uint8Array(item))
break;
case IPFSHashVersion.CIDv1:
const base32Hash = CIDTool.base32(ipfsHash)
fileResult = await fetch(`https://cloudflare-ipfs.com/ipfs/${base32Hash}${ipfsPath}`)
fileResult = await fetch(`${this.ipfsEndpointInfo.url}/${ipfsHash}${ipfsPath}`)
.then(item => item.arrayBuffer())
.then(item => new Uint8Array(item))
break;
Expand Down
2 changes: 1 addition & 1 deletion packages/augur-utils/src/extract-ipfs-url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export function extractIPFSUrl(urlString: string): IPFSEndpointInfo {
const matches = cidV1Pattern.exec(url.hostname);
return {
version: IPFSHashVersion.CIDv1,
url: `.ipfs.${matches[1]}`
url: `${url.protocol}//${matches[1]}/ipfs`
}
}

Expand Down

0 comments on commit 7a433ef

Please sign in to comment.