/** * Points at the instance an account from another gerbeur comes from, its * home, where its password, email, avatar and name are changed. Such a user's * handle here is `name@host` (`splitHandle`); the profile, the settings and * the `/authorize` page read it through these. * * @module */ import { splitHandle } from "../../../shared/validation.ts"; import { userPath } from "../../../shared/paths.ts"; /** * Returns the host of `handle`'s home instance, or undefined for a local * user. */ export function homeHost(handle: string): string | undefined { return splitHandle(handle).host; } /** * Returns the URL of `path` on `handle`'s home instance, their profile there * by default, or null for a local user. Instances speak the same protocol as * this page, https outside development. */ export function homeUrl(handle: string, path?: string): string | null { const { name, host } = splitHandle(handle); if (!host) return null; return `${globalThis.location.protocol}//${host}${path ?? userPath(name)}`; }