normalizeKeyId
Normalizes a key ID by extracting the fragment identifier.
Key IDs can be provided in multiple formats:
Full DID URL:
did:key:z6Mk...#key-1→ returnskey-1Fragment only:
#key-1→ returnskey-1Plain key ID:
key-1→ returnskey-1
Example:
normalizeKeyId("did:key:z6Mk...#key-1") // returns "key-1"
normalizeKeyId("#key-1") // returns "key-1"
normalizeKeyId("key-1") // returns "key-1"
normalizeKeyId("did:key:z6Mk...") // returns "did:key:z6Mk..."Content copied to clipboard
Return
The normalized key ID (fragment part if present, otherwise the original keyId)
Parameters
keyId
The key ID to normalize (may include DID URL or fragment)