fix: use cookie-es

This commit is contained in:
Pooya Parsa 2021-11-23 00:20:20 +01:00
parent 0db1002a3b
commit 8994b5a368
4 changed files with 15 additions and 9 deletions

View File

@ -29,7 +29,7 @@
"@vueuse/head": "^0.7.2", "@vueuse/head": "^0.7.2",
"acorn": "^8.6.0", "acorn": "^8.6.0",
"consola": "^2.15.3", "consola": "^2.15.3",
"cookie": "^0.4.1", "cookie-es": "^0.5.0",
"defu": "^5.0.0", "defu": "^5.0.0",
"destr": "^1.1.0", "destr": "^1.1.0",
"enhanced-resolve": "^5.8.3", "enhanced-resolve": "^5.8.3",

View File

@ -31,7 +31,7 @@
"@vueuse/head": "^0.7.2", "@vueuse/head": "^0.7.2",
"chokidar": "^3.5.2", "chokidar": "^3.5.2",
"consola": "^2.15.3", "consola": "^2.15.3",
"cookie": "^0.4.1", "cookie-es": "^0.5.0",
"defu": "^5.0.0", "defu": "^5.0.0",
"destr": "^1.1.0", "destr": "^1.1.0",
"globby": "^11.0.4", "globby": "^11.0.4",

View File

@ -1,7 +1,6 @@
import type { ServerResponse } from 'http' import type { ServerResponse } from 'http'
import { Ref, ref, watch } from 'vue' import { Ref, ref, watch } from 'vue'
import type { CookieParseOptions, CookieSerializeOptions } from 'cookie' import { parse, serialize, CookieParseOptions, CookieSerializeOptions } from 'cookie-es'
import * as cookie from 'cookie'
import { appendHeader } from 'h3' import { appendHeader } from 'h3'
import type { NuxtApp } from '@nuxt/schema' import type { NuxtApp } from '@nuxt/schema'
import destr from 'destr' import destr from 'destr'
@ -50,9 +49,9 @@ function useSSRRes (nuxtApp?: NuxtApp = useNuxtApp()) { return nuxtApp.ssrContex
function readRawCookies (opts: CookieOptions = {}): Record<string, string> { function readRawCookies (opts: CookieOptions = {}): Record<string, string> {
if (process.server) { if (process.server) {
return cookie.parse(useSSRReq().headers.cookie || '', opts) return parse(useSSRReq().headers.cookie || '', opts)
} else if (process.client) { } else if (process.client) {
return cookie.parse(document.cookie, opts) return parse(document.cookie, opts)
} }
} }
@ -60,7 +59,7 @@ function serializeCookie (name: string, value: any, opts: CookieSerializeOptions
if (value === null || value === undefined) { if (value === null || value === undefined) {
opts.maxAge = -1 opts.maxAge = -1
} }
return cookie.serialize(name, value, opts) return serialize(name, value, opts)
} }
function writeClientCookie (name: string, value: any, opts: CookieSerializeOptions = {}) { function writeClientCookie (name: string, value: any, opts: CookieSerializeOptions = {}) {

View File

@ -2436,7 +2436,7 @@ __metadata:
"@vueuse/head": ^0.7.2 "@vueuse/head": ^0.7.2
acorn: ^8.6.0 acorn: ^8.6.0
consola: ^2.15.3 consola: ^2.15.3
cookie: ^0.4.1 cookie-es: ^0.5.0
defu: ^5.0.0 defu: ^5.0.0
destr: ^1.1.0 destr: ^1.1.0
enhanced-resolve: ^5.8.3 enhanced-resolve: ^5.8.3
@ -7912,6 +7912,13 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"cookie-es@npm:^0.5.0":
version: 0.5.0
resolution: "cookie-es@npm:0.5.0"
checksum: afe924dd44e2c9aaa60ed77e78182e44324acd0a155ea947bb0174e5c48625ee277b004bfbca1bc6cfd24955f2b4039813c7c88bd9d7921ca475eae0286d2666
languageName: node
linkType: hard
"cookie@npm:^0.3.1": "cookie@npm:^0.3.1":
version: 0.3.1 version: 0.3.1
resolution: "cookie@npm:0.3.1" resolution: "cookie@npm:0.3.1"
@ -15295,7 +15302,7 @@ __metadata:
"@vueuse/head": ^0.7.2 "@vueuse/head": ^0.7.2
chokidar: ^3.5.2 chokidar: ^3.5.2
consola: ^2.15.3 consola: ^2.15.3
cookie: ^0.4.1 cookie-es: ^0.5.0
defu: ^5.0.0 defu: ^5.0.0
destr: ^1.1.0 destr: ^1.1.0
globby: ^11.0.4 globby: ^11.0.4