Skip to content

Commit

Permalink
refactor: setup maxAge in seconds
Browse files Browse the repository at this point in the history
  • Loading branch information
Kikobeats committed May 3, 2022
1 parent 9d8d676 commit e8233df
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
3 changes: 1 addition & 2 deletions packages/next/server/web/spec-extension/cookies.ts
Expand Up @@ -5,8 +5,7 @@ const normalizeCookieOptions = (options: CookieSerializeOptions) => {
options = Object.assign({}, options)

if (options.maxAge) {
options.expires = new Date(Date.now() + options.maxAge)
options.maxAge /= 1000
options.expires = new Date(Date.now() + options.maxAge * 1000)
}

if (options.path == null) {
Expand Down
4 changes: 2 additions & 2 deletions test/unit/web-runtime/cookies.test.ts
Expand Up @@ -55,7 +55,7 @@ it('.set with options', async () => {

const options: CookieSerializeOptions = {
path: '/',
maxAge: 1000 * 60 * 60 * 24 * 7,
maxAge: 60 * 60 * 24 * 7,
httpOnly: true,
sameSite: 'strict',
domain: 'example.com',
Expand All @@ -65,7 +65,7 @@ it('.set with options', async () => {

expect(options).toStrictEqual({
path: '/',
maxAge: 1000 * 60 * 60 * 24 * 7,
maxAge: 60 * 60 * 24 * 7,
httpOnly: true,
sameSite: 'strict',
domain: 'example.com',
Expand Down

0 comments on commit e8233df

Please sign in to comment.