mirror of
https://github.com/getpaseo/paseo.git
synced 2026-07-29 12:01:31 +00:00
21 lines
524 B
TypeScript
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;
|
|
}
|