PinataCloud/ipfs-gateway-tools

several false positive for containsCID

Closed this issue · 7 comments

Here is one example https://www.supbirds.com/meta/59.json I can produce several more...

        if(gatewayTools.containsCID(json.image)){
            try {
                image = gatewayTools.convertToDesiredGateway(json.image, gateway);
            }catch(error){
                console.log(error)
                image = json.image;
            }
        } 

Hello @nschwermann,

Not sure I understand the problem, this package assumes there's a CID on the URL. However, 59.json is not a proper CID. That's why it throws an error.

@rommel-pinata are you saying gatewayTools.containsCID assumes the url passed to will always contain a CID? Do I not understand its usecase? It should return false for the url I provided not throw an error (which it doesn't throw an error it returns true)

Screen Shot 2022-04-08 at 08 49 56

I added your URL to my spec and it return false.

Thanks @nschwermann, @starryeyez024 You can close this issue :)

0x-jj commented

@rommel-pinata I have encountered a false positive

gatewayTools.containsCID('https://api.niftygateway.com/lucid-dreams-angels/193');
{ containsCid: true, cid: '193' }

Thanks @0x-jj I was able to reproduce the error, I'll create an issue about it.