Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | 45x 45x 45x 4x | import { LOCALE_COOKIE } from "./constants"; import { takeCookie } from "./cookies"; import { isLocale, Locale } from "./locale"; import { ServerApiContext } from "types/serverContext"; export function getValidCookieLocale(context: ServerApiContext): Locale | null { const localeHeader = context.req.headers["x-locale"]?.toString(); const localeCookieValue = takeCookie(LOCALE_COOKIE, context); const localeCookie = localeCookieValue ?? localeHeader; Iif (localeCookie && isLocale(localeCookie)) return localeCookie; return null; } |