Skip to content

uriToEntryIdAndDigest

uriToEntryIdAndDigest(registryEntryUri): object

Extracts the identifier and digest from a given registry entry URI.

registryEntryUri: `entry:cord:${string}`

The registry entry URI to be parsed. Format: ‘entry:cord::‘.

object

An object containing the extracted identifier and digest.

digest: HexString

identifier: string

This function parses a registry entry URI and extracts the identifier and digest components.

const entryUri = 'entry:cord:1234:abcd';
const { identifier, digest } = uriToEntryIdAndDigest(entryUri);
console.log('Identifier:', identifier, 'Digest:', digest);

If the registryEntryUri does not follow the expected format.

The function splits the registryEntryUri string and validates its format. If valid, it returns the identifier and the digest (with ‘0x’ prefix).

identifier/src/Identifier.ts:905