Skip to content

buildRegistryEntryUri

buildRegistryEntryUri(idDigest, digest): EntryUri

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

Parameters

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’.

Returns

EntryUri

A RegistryEntryUri representing the combined URI for the entry.

Remarks

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.

Example

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

Throws

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

Description

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.

Source

identifier/src/Identifier.ts:816