cookies-next
Advanced tools
Comparing version 4.1.1 to 4.2.0
@@ -50,6 +50,8 @@ "use strict"; | ||
var stringify = function (value) { | ||
if (value === void 0) { value = ''; } | ||
try { | ||
var result = JSON.stringify(value); | ||
return /^[\{\[]/.test(result) ? result : value; | ||
if (typeof value === 'string') { | ||
return value; | ||
} | ||
var stringifiedValue = JSON.stringify(value); | ||
return stringifiedValue; | ||
} | ||
@@ -109,3 +111,3 @@ catch (e) { | ||
var req = options.req, res = options.res, cookiesFn = options.cookies, restOptions = __rest(options, ["req", "res", "cookies"]); | ||
var payload = __assign({ name: key, value: data }, restOptions); | ||
var payload = __assign({ name: key, value: stringify(data) }, restOptions); | ||
if (req) { | ||
@@ -112,0 +114,0 @@ req.cookies.set(payload); |
{ | ||
"name": "cookies-next", | ||
"version": "4.1.1", | ||
"version": "4.2.0", | ||
"description": "Getting, setting and removing cookies on both client and server with next.js", | ||
@@ -38,7 +38,7 @@ "main": "lib/index.js", | ||
"dependencies": { | ||
"@types/cookie": "^0.6.0", | ||
"@types/node": "^16.10.2", | ||
"cookie": "^0.6.0" | ||
}, | ||
"devDependencies": { | ||
"@types/cookie": "^0.6.0", | ||
"@types/node": "^16.10.2", | ||
"next": "^13.4.19", | ||
@@ -45,0 +45,0 @@ "prettier": "^3.0.2", |
@@ -46,6 +46,9 @@ import { serialize, parse } from 'cookie'; | ||
const stringify = (value: string = '') => { | ||
const stringify = (value: any) => { | ||
try { | ||
const result = JSON.stringify(value); | ||
return /^[\{\[]/.test(result) ? result : value; | ||
if (typeof value === 'string') { | ||
return value; | ||
} | ||
const stringifiedValue = JSON.stringify(value); | ||
return stringifiedValue; | ||
} catch (e) { | ||
@@ -110,3 +113,3 @@ return value; | ||
const { req, res, cookies: cookiesFn, ...restOptions } = options; | ||
const payload = { name: key, value: data, ...restOptions }; | ||
const payload = { name: key, value: stringify(data), ...restOptions }; | ||
if (req) { | ||
@@ -113,0 +116,0 @@ req.cookies.set(payload); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
28866
1
382
5
1
- Removed@types/cookie@^0.6.0
- Removed@types/node@^16.10.2
- Removed@types/cookie@0.6.0(transitive)
- Removed@types/node@16.18.119(transitive)