edge-runtime
edge-runtime copied to clipboard
cookie: `parseSetCookie` ignores `Max-Age` attribute
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
Made a fix https://github.com/vercel/edge-runtime/pull/995