Sha256: e46909dd303e0e34359b9ca3d3bbbfe6007d03a9944dc80883174048c0c2f206
Contents?: true
Size: 1.48 KB
Versions: 26
Compression:
Stored size: 1.48 KB
Contents
import cookieUtils from "@bundled-es-modules/cookie"; import { cookieStore } from '../cookieStore.mjs'; function getAllDocumentCookies() { return cookieUtils.parse(document.cookie); } function getDocumentCookies(request) { if (typeof document === "undefined" || typeof location === "undefined") { return {}; } switch (request.credentials) { case "same-origin": { const requestUrl = new URL(request.url); return location.origin === requestUrl.origin ? getAllDocumentCookies() : {}; } case "include": { return getAllDocumentCookies(); } default: { return {}; } } } function getAllRequestCookies(request) { const requestCookieHeader = request.headers.get("cookie"); const cookiesFromHeaders = requestCookieHeader ? cookieUtils.parse(requestCookieHeader) : {}; const cookiesFromDocument = getDocumentCookies(request); for (const name in cookiesFromDocument) { request.headers.append( "cookie", cookieUtils.serialize(name, cookiesFromDocument[name]) ); } const cookiesFromStore = cookieStore.getCookiesSync(request.url); const storedCookiesObject = Object.fromEntries( cookiesFromStore.map((cookie) => [cookie.key, cookie.value]) ); for (const cookie of cookiesFromStore) { request.headers.append("cookie", cookie.toString()); } return { ...cookiesFromDocument, ...storedCookiesObject, ...cookiesFromHeaders }; } export { getAllRequestCookies }; //# sourceMappingURL=getRequestCookies.mjs.map
Version data entries
26 entries across 26 versions & 1 rubygems