fix: handle full DID in fromShortDid to prevent double did: prefix
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
export const toShortDid = (did: string) => did.replace(/^did:(plc:)?/, "")
|
||||
// did:plc:xxx → xxx, did:web:x → web:x
|
||||
|
||||
export const fromShortDid = (shortDid: string) =>
|
||||
shortDid.includes(":") ? `did:${shortDid}` : `did:plc:${shortDid}`
|
||||
// xxx → did:plc:xxx, web:x → did:web:x
|
||||
export const fromShortDid = (shortDid: string) => {
|
||||
if (shortDid.startsWith("did:")) return shortDid
|
||||
return shortDid.includes(":") ? `did:${shortDid}` : `did:plc:${shortDid}`
|
||||
}
|
||||
// xxx → did:plc:xxx, web:x → did:web:x, did:plc:xxx → did:plc:xxx (passthrough)
|
||||
|
||||
Reference in New Issue
Block a user