From 3fe394d88ce5fd36b5e3c891d75e8c861b7e12a4 Mon Sep 17 00:00:00 2001 From: Andreas Richter <708186+richtera@users.noreply.github.com> Date: Tue, 17 Sep 2024 10:09:46 -0400 Subject: [PATCH] fix: Repair patchIPFSUrlsIfApplicable to only map urls starting with ipfs:// --- package.json | 2 +- src/lib/utils.ts | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 3c6d4bb4..223c980c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@erc725/erc725.js", - "version": "0.27.2", + "version": "0.27.3", "description": "Library to interact with ERC725 smart contracts", "main": "build/main/src/index.js", "typings": "build/main/src/index.d.ts", diff --git a/src/lib/utils.ts b/src/lib/utils.ts index 66b8eddf..d156d564 100644 --- a/src/lib/utils.ts +++ b/src/lib/utils.ts @@ -613,7 +613,9 @@ export function patchIPFSUrlsIfApplicable( receivedData: URLDataWithHash, ipfsGateway: string, ): URLDataWithHash { - if (receivedData?.url?.indexOf('ipfs://') !== -1) { + // Only map URL if it's indeed an ipfs:// URL and ignore if it's a data:// URL with JSON + // possibly containing an IPFS URL inside of the JSON data. + if (receivedData?.url?.startsWith('ipfs://')) { return { ...receivedData, url: receivedData.url.replace('ipfs://', ipfsGateway),