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

@@ -3,6 +3,7 @@ import { ComputedRef, onUnmounted, Ref, toValue } from "vue"
import { isExternalLink } from "@/utils/link"
import { useRouteQueryStackedNotes } from "@/hooks/useRouteQueryStackedNotes.hook"
import { parseAtUri } from "@/modules/atproto/parseAtUri"
import { toShortDid } from "@/modules/atproto/shortDid"
import { router } from "@/router/router"
export const useATProtoLinks = (
@@ -35,25 +36,25 @@ export const useATProtoLinks = (
href.replace(window.location.origin, ""),
)
if (!params.did || !params.rkey) {
if (!params.shortDid || !params.rkey) {
return
}
const noteId = params.slug
? `${params.did}-${params.rkey}-${params.slug}`
: `${params.did}-${params.rkey}`
? `${params.shortDid}-${params.rkey}-${params.slug}`
: `${params.shortDid}-${params.rkey}`
addStackedNote(
toValue(currentAtUri) ?? "",
noteId,
`${params.did}-${params.rkey}`,
`${params.shortDid}-${params.rkey}`,
)
return
}
if (href.startsWith("at://")) {
const { did, rkey } = parseAtUri(href)
const noteId = `${did}-${rkey}`
const noteId = `${toShortDid(did)}-${rkey}`
addStackedNote(toValue(currentAtUri) ?? "", noteId)
}