Skip to content

Commit

Permalink
fix: Repair IPFS decoding in lsp-factory when using custom authentica…
Browse files Browse the repository at this point in the history
…ted gateway.
  • Loading branch information
richtera committed Dec 9, 2023
1 parent 4e3bd7f commit 2b2496b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
1 change: 1 addition & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodejs 16.14.2
11 changes: 7 additions & 4 deletions src/lib/helpers/uploader.helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,11 +179,14 @@ export function formatIPFSUrl(ipfsGateway: IPFSGateway, ipfsHash: string) {
ipfsUrl = ipfsGateway.endsWith('/')
? `${ipfsGateway}${ipfsHash}`
: `${ipfsGateway}/${ipfsHash}`;
} else if (
ipfsGateway.url &&
(typeof ipfsGateway.url === 'string' || ipfsGateway.url instanceof URL)
) {
const url = new URL(ipfsGateway.url);
ipfsUrl = new URL(`/ipfs/${ipfsHash}`, url).toString();
} else {
const protocol = ipfsGateway?.host ?? 'https';
const host = ipfsGateway?.host ?? '2eff.lukso.dev';

ipfsUrl = `${[protocol]}://${host}/ipfs/${ipfsHash}`;
throw new Error('IPFS gateway as Multiaddr is currently not supported');
}

return ipfsUrl;
Expand Down

0 comments on commit 2b2496b

Please sign in to comment.