import { FRONTEND_URL, PUBLIC_URL } from "../config.ts"; const SELF_HOSTS = new Set( [PUBLIC_URL, FRONTEND_URL].flatMap((u) => { try { return [new URL(u).host.toLowerCase()]; } catch { return []; } }), ); const SELF_PATH_RE = /^\/(dumps|users|playlists)\/[^/]+$/; /** * A link to one of this site's own dump, user or playlist pages. Matched on the * host as well as the path: `/users/bob` on some other site is someone else's * page, not ours. */ export function isSelfUrl(url: URL): boolean { return SELF_HOSTS.has(url.host.toLowerCase()) && SELF_PATH_RE.test(url.pathname); }