Files
paseo/packages/app/src/utils/active-host.ts
2026-04-20 18:06:09 +07:00

21 lines
524 B
TypeScript

import type { HostProfile } from "@/types/host-connection";
import { parseServerIdFromPathname } from "@/utils/host-routes";
export function resolveActiveHost({
hosts,
pathname,
}: {
hosts: readonly HostProfile[];
pathname: string;
}): HostProfile | null {
const serverIdFromPath = parseServerIdFromPathname(pathname);
if (serverIdFromPath) {
const routeMatch = hosts.find((host) => host.serverId === serverIdFromPath);
if (routeMatch) {
return routeMatch;
}
}
return hosts[0] ?? null;
}