edge-runtime icon indicating copy to clipboard operation
edge-runtime copied to clipboard

cookie: `parseSetCookie` ignores `Max-Age` attribute

Open kasmacioma opened this issue 1 year ago • 1 comments

Bug Report

Current behavior

parseSetCookie ignores the Max-Age attribute when parsing a cookie. For example, this code:

import { parseSetCookie } from "@edge-runtime/cookies";

console.log(parseSetCookie("foo=bar; Max-Age=86400; Path=/; SameSite=none; HttpOnly; Secure"));

will output the following to the console:

{
  name: 'foo',
  value: 'bar',
  httpOnly: true,
  path: '/',
  sameSite: 'none',
  secure: true
}

Expected behavior/code

The above code sample should output:

{
  name: 'foo',
  value: 'bar',
  httpOnly: true,
  maxAge: 86400,
  path: '/',
  sameSite: 'none',
  secure: true
}

Possible solution

Since the Max-Age attribute (unlike the others) contains a hyphen in its name, here should be something like "max-age": maxage

kasmacioma avatar Aug 12 '24 11:08 kasmacioma

Made a fix https://github.com/vercel/edge-runtime/pull/995

sibiraj-s avatar Oct 12 '24 11:10 sibiraj-s