diff --git a/thoughts-frontend/components/remote-user-card.tsx b/thoughts-frontend/components/remote-user-card.tsx index df7cc93..07bc8bc 100644 --- a/thoughts-frontend/components/remote-user-card.tsx +++ b/thoughts-frontend/components/remote-user-card.tsx @@ -18,6 +18,19 @@ interface RemoteUserCardProps { }; } +function resolveProfileHref(handle: string): string { + const apiDomain = process.env.NEXT_PUBLIC_API_URL + ? new URL(process.env.NEXT_PUBLIC_API_URL).hostname + : null; + const clean = handle.startsWith("@") ? handle.slice(1) : handle; + const atIdx = clean.indexOf("@"); + const domain = atIdx !== -1 ? clean.slice(atIdx + 1) : null; + const username = atIdx !== -1 ? clean.slice(0, atIdx) : clean; + return apiDomain && domain === apiDomain + ? `/users/${username}` + : `/remote-actor?handle=@${clean}`; +} + export function RemoteUserCard({ actor }: RemoteUserCardProps) { const [followed, setFollowed] = useState(false); const [loading, setLoading] = useState(false); @@ -43,7 +56,7 @@ export function RemoteUserCard({ actor }: RemoteUserCardProps) { return (