Something went wrong. Try again.
This repository has no description
Something went wrong. Try again.
972 B · 38 lines
TypeScript
123456789101112131415161718192021222324252627282930313233343536373839export type Domain = { revision: number; origin: string | null; hostname: string; zoneId: string; domainId: string | null; operationId: string; status: "connecting" | "active" | "removing" | "removed" | "failed"; errorCode: string | null; action: "attach" | "remove";};export type DomainDetails = { ownerSubject: string; installationId: string; accountId: string; runtimeOrigin: string; domain: Domain | null;};export type Zone = { id: string; name: string };
export function validOrigin(value: unknown) { try { if (typeof value !== "string") return false; const url = new URL(value); const local = ["localhost", "127.0.0.1"].includes(url.hostname); return ( !url.username && !url.password && url.pathname === "/" && !url.search && !url.hash && url.origin === value && (url.protocol === "https:" || (url.protocol === "http:" && local)) ); } catch { return false; }}