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

react-cookie

Package Overview
Dependencies
Maintainers
1
Versions
84
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-cookie - npm Package Compare versions

Comparing version 0.3.4 to 0.4.0

33

index.js

@@ -44,13 +44,16 @@ var cookie = require('cookie');

function remove(name, path) {
function remove(name, opt) {
delete _rawCookie[name];
if (typeof document !== 'undefined') {
var removeCookie = name + '=; expires=Thu, 01 Jan 1970 00:00:01 GMT;';
if (path) {
removeCookie += ' path=' + path;
if (typeof opt === 'undefined') {
opt = {};
} else if (typeof opt === 'string') {
// Will be deprecated in future versions
opt = { path: opt };
}
document.cookie = removeCookie;
opt.expires = new Date(1970, 1, 1, 0, 0, 1);
document.cookie = cookie.serialize(name, '', opt);
}

@@ -65,12 +68,16 @@

function setRawCookie(rawCookie) {
_rawCookie = cookie.parse(rawCookie);
if (rawCookie) {
_rawCookie = cookie.parse(rawCookie);
} else {
_rawCookie = {};
}
}
function plugToRequest(req, res) {
if (req) {
if (req.cookie) {
_rawCookie = req.cookie;
} else if (req.headers && req.headers.cookie) {
setRawCookie(req.headers.cookie);
}
if (req.cookie) {
_rawCookie = req.cookie;
} else if (req.headers && req.headers.cookie) {
setRawCookie(req.headers.cookie);
} else {
_rawCookie = {};
}

@@ -77,0 +84,0 @@

{
"name": "react-cookie",
"version": "0.3.4",
"version": "0.4.0",
"description": "Load and save cookies within your React application",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -13,3 +13,3 @@ # react-cookie

Bower: `bower install react-cookie`<br />
CDN: `https://cdnjs.cloudflare.com/ajax/libs/react-cookie/0.2.6/react-cookie.min.js`
CDN: `https://cdnjs.cloudflare.com/ajax/libs/react-cookie/0.3.4/react-cookie.min.js`

@@ -88,3 +88,3 @@ # Examples

### `reactCookie.save(name, val, [opt])`
### `reactCookie.remove(name, [path])`
### `reactCookie.remove(name, [opt])`
### `reactCookie.plugToRequest(req, res)`

@@ -91,0 +91,0 @@ ### `reactCookie.setRawCookie(cookies)`

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