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

cookie

Package Overview
Dependencies
Maintainers
2
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cookie - npm Package Compare versions

Comparing version 0.7.0 to 0.7.1

58

index.js

@@ -67,5 +67,11 @@ /*!

* <digit> = any one of the ten digits 0 through 9
*
* Keep support for leading dot: https://github.com/jshttp/cookie/issues/173
*
* > (Note that a leading %x2E ("."), if present, is ignored even though that
* character is not permitted, but a trailing %x2E ("."), if present, will
* cause the user agent to ignore the attribute.)
*/
var domainValueRegExp = /^([a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)([.][a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)*$/i;
var domainValueRegExp = /^([.]?[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)([.][a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)*$/i;

@@ -89,3 +95,3 @@ /**

* @param {string} str
* @param {object} [options]
* @param {object} [opt]
* @return {object}

@@ -95,3 +101,3 @@ * @public

function parse(str, options) {
function parse(str, opt) {
if (typeof str !== 'string') {

@@ -104,6 +110,5 @@ throw new TypeError('argument str must be a string');

// RFC 6265 sec 4.1.1, RFC 2616 2.2 defines a cookie name consists of one char minimum, plus '='.
var max = len - 2;
if (max < 0) return obj;
if (len < 2) return obj;
var dec = (options && options.decode) || decode;
var dec = (opt && opt.decode) || decode;
var index = 0;

@@ -115,8 +120,4 @@ var eqIdx = 0;

eqIdx = str.indexOf('=', index);
if (eqIdx === -1) break; // No more cookie pairs.
// no more cookie pairs
if (eqIdx === -1) {
break;
}
endIdx = str.indexOf(';', index);

@@ -137,3 +138,3 @@

// only assign once
if (undefined === obj[key]) {
if (!obj.hasOwnProperty(key)) {
var valStartIdx = startIndex(str, eqIdx + 1, endIdx);

@@ -152,3 +153,3 @@ var valEndIdx = endIndex(str, endIdx, valStartIdx);

index = endIdx + 1
} while (index < max);
} while (index < len);

@@ -185,3 +186,3 @@ return obj;

* @param {string} val
* @param {object} [options]
* @param {object} [opt]
* @return {string}

@@ -191,5 +192,4 @@ * @public

function serialize(name, val, options) {
var opt = options || {};
var enc = opt.encode || encode;
function serialize(name, val, opt) {
var enc = (opt && opt.encode) || encodeURIComponent;

@@ -206,3 +206,3 @@ if (typeof enc !== 'function') {

if (value && !cookieValueRegExp.test(value)) {
if (!cookieValueRegExp.test(value)) {
throw new TypeError('argument val is invalid');

@@ -212,5 +212,6 @@ }

var str = name + '=' + value;
if (!opt) return str;
if (null != opt.maxAge) {
var maxAge = opt.maxAge - 0;
var maxAge = Math.floor(opt.maxAge);

@@ -221,3 +222,3 @@ if (!isFinite(maxAge)) {

str += '; Max-Age=' + Math.floor(maxAge);
str += '; Max-Age=' + maxAge;
}

@@ -265,4 +266,3 @@

var priority = typeof opt.priority === 'string'
? opt.priority.toLowerCase()
: opt.priority
? opt.priority.toLowerCase() : opt.priority;

@@ -323,13 +323,2 @@ switch (priority) {

/**
* URL-encode value.
*
* @param {string} val
* @returns {string}
*/
function encode (val) {
return encodeURIComponent(val)
}
/**
* Determine if value is a Date.

@@ -342,4 +331,3 @@ *

function isDate (val) {
return __toString.call(val) === '[object Date]' ||
val instanceof Date
return __toString.call(val) === '[object Date]';
}

@@ -346,0 +334,0 @@

{
"name": "cookie",
"description": "HTTP server cookie parsing and serialization",
"version": "0.7.0",
"version": "0.7.1",
"author": "Roman Shtylman <shtylman@gmail.com>",

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

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