CID.parse constructor

CID.parse(
  1. String cid
)

Returns the new instance of CID based on string cid.

Implementation

factory CID.parse(final String cid) {
  if (!cid.startsWith('b')) {
    throw InvalidCidError('CID v1 should be encoded in base32 format');
  }

  // Decode exactly once, then validate the decoded bytes.
  return CID(_ensureBytesFormat(_decode(cid)));
}