Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cookies-next

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cookies-next - npm Package Compare versions

Comparing version 4.1.1 to 4.2.0

10

lib/index.js

@@ -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);

6

package.json
{
"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);

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc