mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-13 09:33:54 +00:00
fix(nuxt): better equality check for json cookies (#6352)
This commit is contained in:
parent
d8cdd97f02
commit
4732d2ce3a
@ -3,6 +3,7 @@ import { parse, serialize, CookieParseOptions, CookieSerializeOptions } from 'co
|
|||||||
import { appendHeader } from 'h3'
|
import { appendHeader } from 'h3'
|
||||||
import type { CompatibilityEvent } from 'h3'
|
import type { CompatibilityEvent } from 'h3'
|
||||||
import destr from 'destr'
|
import destr from 'destr'
|
||||||
|
import { isEqual } from 'ohash'
|
||||||
import { useRequestEvent } from './ssr'
|
import { useRequestEvent } from './ssr'
|
||||||
import { wrapInRef } from './utils'
|
import { wrapInRef } from './utils'
|
||||||
import { useNuxtApp } from '#app'
|
import { useNuxtApp } from '#app'
|
||||||
@ -34,7 +35,7 @@ export function useCookie <T=string> (name: string, _opts?: CookieOptions<T>): C
|
|||||||
} else if (process.server) {
|
} else if (process.server) {
|
||||||
const nuxtApp = useNuxtApp()
|
const nuxtApp = useNuxtApp()
|
||||||
const writeFinalCookieValue = () => {
|
const writeFinalCookieValue = () => {
|
||||||
if (cookie.value !== cookies[name]) {
|
if (!isEqual(cookie.value, cookies[name])) {
|
||||||
writeServerCookie(useRequestEvent(nuxtApp), name, cookie.value, opts)
|
writeServerCookie(useRequestEvent(nuxtApp), name, cookie.value, opts)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user