Vana SDK - v2.2.2
    Preparing search index...

    Function extractIpfsHash

    • Extract IPFS hash from various URL formats

      Edge Cases:

      • Returns null for non-IPFS URLs or malformed hashes
      • Handles both CIDv0 (starts with Qm) and CIDv1 formats
      • Minimum 46 characters required for standalone hash detection
      • Gateway paths with subdirectories are not supported

      Parameters

      • url: string

        The URL to extract hash from

      Returns string | null

      The IPFS hash or null if not found

      extractIpfsHash("ipfs://QmHash123") // Returns: "QmHash123"
      extractIpfsHash("https://gateway.pinata.cloud/ipfs/QmHash123") // Returns: "QmHash123"
      extractIpfsHash("QmHash123456789012345678901234567890123456") // Returns: "QmHash123456789012345678901234567890123456"
      extractIpfsHash("https://example.com/file.json") // Returns: null (not IPFS)
      extractIpfsHash("ipfs://QmHash/subdirectory") // Returns: null (subdirectories not supported)