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 bd1bcc7 commit 0becba4
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 @@ -191,11 +191,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 0becba4

Please sign in to comment.