mirror of
https://github.com/vercel/commerce.git
synced 2025-07-04 20:21:21 +00:00
13 lines
368 B
TypeScript
13 lines
368 B
TypeScript
export function prepareSetCookie(name: string, value: string, options: any = {}): string {
|
|
const cookieValue = [`${name}=${value}`];
|
|
|
|
if (options.maxAge) {
|
|
cookieValue.push(`Max-Age=${options.maxAge}`);
|
|
}
|
|
|
|
if (options.expires && !options.maxAge) {
|
|
cookieValue.push(`Expires=${options.expires.toUTCString()}`);
|
|
}
|
|
|
|
return cookieValue.join('; ');
|
|
} |