diff --git a/web/lib/util/cookie.ts b/web/lib/util/cookie.ts index 4ffee21e..14999fd4 100644 --- a/web/lib/util/cookie.ts +++ b/web/lib/util/cookie.ts @@ -23,5 +23,11 @@ export const setCookie = (name: string, val: string, opts?: CookieOptions) => { // Note that this intentionally ignores the case where multiple cookies have // the same name but different paths. Hopefully we never need to think about it. -export const getCookies = (cookies: string) => - Object.fromEntries(cookies.split(';').map(decodeCookie)) +export const getCookies = (cookies: string) => { + const data = cookies.trim() + if (!data) { + return {} + } else { + return Object.fromEntries(data.split(';').map(decodeCookie)) + } +}