Skip to content

buildRegistryEntryUri

buildRegistryEntryUri(idDigest, digest): EntriesUri

Constructs a registry-entry URI from given hexadecimal string digests.

idDigest: HexString

A hexadecimal string representing the identifier digest. Must start with ‘0x’.

digest: HexString

Another hexadecimal string representing the registry entry’s content digest. Must also start with ‘0x’.

EntriesUri

A RegistryEntryUri representing the combined URI for the entry.

This function generates a standardized URI for a registry entry by combining a hashed identifier digest and another digest. The identifier digest is first converted to a URI with a specific prefix, and then concatenated with the sliced second digest to form the complete registry-entry URI.

const idDigest = '0x1234...';
const digest = '0xabcd...';
const entryUri = buildRegistryEntryUri(idDigest, digest);
console.log('Registry Entry URI:', entryUri);

If either idDigest or digest does not start with ‘0x’.

The function first checks if both input parameters start with ‘0x’ as required for hexadecimal digests. It then uses the hashToUri function to convert idDigest to a URI with a specified identifier and prefix. The digest is then sliced to remove its ‘0x’ prefix and concatenated with the identifier URI to form the final registry entry URI, which is returned as a RegistryEntryUri type.

identifier/src/Identifier.ts:822