@fastly/compute-js-static-publish
Version:
Static Publisher for Fastly Compute JavaScript
15 lines (14 loc) • 392 B
JavaScript
/*
* Copyright Fastly, Inc.
* Licensed under the MIT license. See LICENSE file for details.
*/
export function getCookieValue(request, name) {
const cookieHeader = request.headers.get('Cookie');
if (!cookieHeader) {
return null;
}
return cookieHeader
.split(';')
.map(v => v.trim().split('='))
.find(([key]) => key === name)?.[1] ?? null;
}