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

browser-cookies

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

browser-cookies - npm Package Compare versions

Comparing version 1.0.6 to 1.0.7

19

browser-cookies.js

@@ -19,3 +19,3 @@ exports.defaults = {};

// in case expires is an integer, it (should) specify the amount in days till the cookie expires
typeof expires == 'number' ? new Date(new Date().getTime() + (expires * 864e5)) :
typeof expires == 'number' ? new Date((new Date()).getTime() + (expires * 864e5)) :
// in case expires is (probably) a Date object

@@ -27,4 +27,6 @@ expires.getTime ? expires :

// Set cookie
document.cookie = encodeURIComponent(name) + '=' + // Encode cookie name
value.replace(/[^#\$&\+/:<-\[\]-}]/g, encodeURIComponent) + // Encode cookie value (RFC6265)
document.cookie = name.replace(/[^+#$&^`|]/g, encodeURIComponent) // Encode cookie name
.replace('(', '%28')
.replace(')', '%29') +
'=' + value.replace(/[^+#$&/:<-\[\]-}]/g, encodeURIComponent) + // Encode cookie value (RFC6265)
(expDate && expDate.getTime() ? ';expires=' + expDate.toUTCString() : '') + // Add expiration date

@@ -43,2 +45,3 @@ (domain ? ';domain=' + domain : '') + // Add domain

var cookie = cookies[i];
var cookieLength = cookie.length;

@@ -49,7 +52,7 @@ // Determine separator index ("name=value")

// IE<11 emits the equal sign when the cookie value is empty
separatorIndex = separatorIndex < 0 ? cookie.length : separatorIndex;
separatorIndex = separatorIndex < 0 ? cookieLength : separatorIndex;
// Decode the cookie name and remove any leading/trailing spaces, then compare to the requested cookie name
if (decodeURIComponent(cookie.substring(0, separatorIndex).replace(/^\s+|\s+$/g,'')) == name) {
return decodeURIComponent(cookie.substring(separatorIndex + 1, cookie.length));
if (decodeURIComponent(cookie.substring(0, separatorIndex).replace(/^\s+|\s+$/g, '')) == name) {
return decodeURIComponent(cookie.substring(separatorIndex + 1, cookieLength));
}

@@ -66,5 +69,5 @@ }

path: options && options.path,
secure: false,
httponly: false}
secure: 0,
httponly: 0}
);
};
{
"name": "browser-cookies",
"description": "Tiny cookies library for the browser",
"version": "1.0.6",
"version": "1.0.7",
"main": "browser-cookies.js",

@@ -6,0 +6,0 @@ "files": [

@@ -64,3 +64,3 @@ <img width="425" height="200" src="https://raw.githubusercontent.com/voltace/browser-cookies/master/browser-cookies.png"/>

[**cookies.set(** `name`, `value` &#91;, `options`&#93; **)**](#cookies-set)
[cookies.set(`name`, `value` &#91;, `options`&#93;)](#cookies-set)
<br/>

@@ -78,3 +78,3 @@ Method to save a cookie.

[**cookies.get(** `name` **)**](#cookies-get)
[cookies.get(`name`)](#cookies-get)
<br/>

@@ -90,3 +90,3 @@ Method that returns a cookie value, or **null** if the cookie is not found.

[**cookies.erase(** `name` &#91;, `options` &#93; **)**](#cookies-erase)
[cookies.erase(`name` &#91;, `options` &#93;)](#cookies-erase)
<br/>

@@ -103,3 +103,3 @@ Method to remove a cookie.

[**cookies.defaults**](#cookies-defaults)
[cookies.defaults](#cookies-defaults)
<br/>

@@ -163,4 +163,2 @@ This object may be used to change the default value of each option specified in [options](#options) below.

- Additional tests:
- Extend test cases to verify proper cookie name encoding/decoding (stubbed and non-stubbed).
- More bad weather scenarios.
- Mobile browser testing (Disabled automated testing for mobile browsers because the results varied per run).

@@ -167,0 +165,0 @@ - Manually verify support on old browsers that that still need to be supported (i.e. IE6)?

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