trimPrefix
trimPrefix(
input,prefix):string
Trims a specified prefix from an input string and returns the remaining part. If the prefix is not present, returns the original string.
Parameters
Section titled “Parameters”• input: string
The input string to process (e.g., ‘registry:cord:abcd’).
• prefix: string
The prefix to remove (e.g., ‘registry:cord:’).
Returns
Section titled “Returns”string
The string with the prefix removed (e.g., ‘abcd’), or the original string if the prefix is not found.
Throws
Section titled “Throws”If the input or prefix is empty or not a string.
Example
Section titled “Example”trimPrefix('registry:cord:abcd', 'registry:cord:') // Returns 'abcd'trimPrefix('did:cord:xyz', 'did:cord:') // Returns 'xyz'trimPrefix('abcd', 'registry:cord:') // Returns 'abcd'