Skip to content

updateRegistryEntryUri

updateRegistryEntryUri(registryEntryUri, digest): EntriesUri

Updates the digest component of a given registry entry URI with a new digest.

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

The original registry entry URI to be updated. Format: ‘entry:cord::‘.

digest: HexString

The new hexadecimal string digest to be inserted into the URI. Must start with ‘0x’.

EntriesUri

The updated registry entry URI with the new digest.

This function modifies an existing registry entry URI by replacing its digest with a new provided digest. It ensures that the URI retains its original structure and prefix, while only the digest part is updated.

const originalUri = 'entry:cord:1234:abcd';
const newDigest = '0x5678...';
const updatedUri = updateRegistryEntryUri(originalUri, newDigest);
console.log('Updated Registry Entry URI:', updatedUri);

If the registryEntryUri does not follow the expected format.

If the new digest does not start with ‘0x’.

The function splits the registryEntryUri and validates its structure. If valid, it replaces the digest with the new one. The updated URI is constructed with the new digest (without ‘0x’ prefix) and returned.

identifier/src/Identifier.ts:863