elementUriToStatementUri
elementUriToStatementUri(
statementUri
):StatementUri
Converts a given element URI to a statement URI.
Parameters
• statementUri: stmt:cord:${string}
The element URI to be converted. Expected format: ‘stmt:cord:<identifier>
:<digest>
‘.
Returns
StatementUri
A statement URI derived from the element URI, excluding the digest component.
Remarks
This function processes an element URI and reformats it to construct a corresponding statement URI. It expects the element URI to follow a specific format and extracts the relevant part to create the statement URI.
Example
const elementUri = 'stmt:cord:1234:abcd';const statementId = elementUriToStatementUri(elementUri);console.log('Statement URI:', statementId);
Throws
If the statementUri
does not conform to the required format.
Description
The function splits the statementUri
and validates its structure against the expected format. If valid, it
constructs a new statement URI using only the ‘stmt:cord:<identifier>
’ part, effectively discarding the digest part.
The new statement URI is then returned.