import { getLotusRoomPermalink } from '../plugins/lotus-permalink'; /** * The public web app's address from config.json `webAppUrl` (the desktop app * sets it; its own origin is a local server). Absolute https only; anything * else is ignored. */ export const resolveWebAppUrl = (value: unknown): string | undefined => { if (typeof value !== 'string' || value.trim() === '') return undefined; try { const url = new URL(value); if (url.protocol !== 'https:') return undefined; return url.origin + url.pathname.replace(/\/+$/, ''); } catch { return undefined; } }; /** * Where to send the user to take a call this app can't make: the room in the * web app (they press Join there themselves — never an auto-join link, which * a crafted URL could abuse to open someone's mic). */ export const getCallInBrowserUrl = ( webAppUrl: string | undefined, roomId: string, ): string | undefined => (webAppUrl ? getLotusRoomPermalink(webAppUrl, roomId) : undefined);