// The one request-header cookie parser (workos.ts, edge/marketing.ts, and the
// SSR auth gate all need it). Pure string code — safe in any bundle.

export const parseCookie = (cookieHeader: string | null, name: string): string | null => {
  if (!cookieHeader) return null;
  const match = cookieHeader
    .split(";")
    .map((c) => c.trim())
    .find((c) => c.startsWith(`${name}=`));
  if (!match) return null;
  return match.slice(name.length + 1) || null;
};
