I want to check provided string is a valid IPFS or IPNS path or not under ipfs domain.
For example when I do:
ipfs ls <invalid-hash> //waits keep searching ...
This will not return anything but halts within the program, so I would need to wait not knowing given hash is valid or not.
I could wait N-seconds as a threshold for ipfs to return results for
ipfs cat valid-hash,
ipfs ls valid-hash but results of
ipfs cat valid-hash or
ipfs ls valid-hash may take longer than N-seconds, which is not trustable to rely on.
[~]$ ipfs cat <hash-id that exists in the ipfs domain> //returns a results maybe after 10 minutes if the hash-id string is valid. [~]$ ipfs cat <hash-id that does not exists in the ipfs domain> //HALTS. and does not return me that hash-id is invalid.
I have used: https://github.com/xicombd/is-ipfs but an invalid-hash string that I am giving into functions returns true, so it does not work properly on my side, any advice?
For example: (I am running commands inside node app.)
[$] node const isIPFS = require('is-ipfs') > isIPFS.multihash('QmYooooooooooooooooooooooooooooooooaoooooooooo') true //returns true but it is an invalid ipfs hash that does not exist in the ipfs domain and should have returned false.
Thank you for your valuable time and help.