Comparing version 0.2.3 to 0.2.4
@@ -0,1 +1,8 @@ | ||
0.2.4 / 2016-05-20 | ||
================== | ||
* perf: enable strict mode | ||
* perf: use for loop in parse | ||
* perf: use string concatination for serialization | ||
0.2.3 / 2015-10-25 | ||
@@ -2,0 +9,0 @@ ================== |
40
index.js
@@ -8,2 +8,4 @@ /*! | ||
'use strict'; | ||
/** | ||
@@ -58,8 +60,9 @@ * Module exports. | ||
pairs.forEach(function(pair) { | ||
var eq_idx = pair.indexOf('=') | ||
for (var i = 0; i < pairs.length; i++) { | ||
var pair = pairs[i]; | ||
var eq_idx = pair.indexOf('='); | ||
// skip things that don't look like key=value | ||
if (eq_idx < 0) { | ||
return; | ||
continue; | ||
} | ||
@@ -79,3 +82,3 @@ | ||
} | ||
}); | ||
} | ||
@@ -115,3 +118,3 @@ return obj; | ||
var pairs = [name + '=' + value]; | ||
var str = name + '=' + value; | ||
@@ -121,3 +124,3 @@ if (null != opt.maxAge) { | ||
if (isNaN(maxAge)) throw new Error('maxAge should be a Number'); | ||
pairs.push('Max-Age=' + Math.floor(maxAge)); | ||
str += '; Max-Age=' + Math.floor(maxAge); | ||
} | ||
@@ -130,3 +133,3 @@ | ||
pairs.push('Domain=' + opt.domain); | ||
str += '; Domain=' + opt.domain; | ||
} | ||
@@ -139,11 +142,22 @@ | ||
pairs.push('Path=' + opt.path); | ||
str += '; Path=' + opt.path; | ||
} | ||
if (opt.expires) pairs.push('Expires=' + opt.expires.toUTCString()); | ||
if (opt.httpOnly) pairs.push('HttpOnly'); | ||
if (opt.secure) pairs.push('Secure'); | ||
if (opt.firstPartyOnly) pairs.push('First-Party-Only'); | ||
if (opt.expires) { | ||
str += '; Expires=' + opt.expires.toUTCString(); | ||
} | ||
return pairs.join('; '); | ||
if (opt.httpOnly) { | ||
str += '; HttpOnly'; | ||
} | ||
if (opt.secure) { | ||
str += '; Secure'; | ||
} | ||
if (opt.firstPartyOnly) { | ||
str += '; First-Party-Only'; | ||
} | ||
return str; | ||
} | ||
@@ -150,0 +164,0 @@ |
{ | ||
"name": "cookie", | ||
"description": "cookie parsing and serialization", | ||
"version": "0.2.3", | ||
"version": "0.2.4", | ||
"author": "Roman Shtylman <shtylman@gmail.com>", | ||
@@ -16,3 +16,3 @@ "contributors": [ | ||
"devDependencies": { | ||
"istanbul": "0.3.22", | ||
"istanbul": "0.4.3", | ||
"mocha": "1.21.5" | ||
@@ -19,0 +19,0 @@ }, |
@@ -61,3 +61,3 @@ # cookie | ||
[node-version-image]: https://img.shields.io/node/v/cookie.svg | ||
[node-version-url]: http://nodejs.org/download/ | ||
[node-version-url]: https://nodejs.org/en/download | ||
[travis-image]: https://img.shields.io/travis/jshttp/cookie/master.svg | ||
@@ -64,0 +64,0 @@ [travis-url]: https://travis-ci.org/jshttp/cookie |
Sorry, the diff of this file is not supported yet
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
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
138
9481