feat: shorten DID in public note URLs by stripping did:plc: prefix

URLs are now /pub/<base32id>/rkey instead of /pub/did:plc:<base32id>/rkey.
Non-plc DIDs keep their method prefix (e.g. web:example.com).
This commit is contained in:
Julien Calixte
2026-03-17 01:33:51 +01:00
parent 5d145dd7ff
commit 163e3ee756
7 changed files with 26 additions and 15 deletions

View File

@@ -0,0 +1,6 @@
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