[Pkg-javascript-commits] [node-cookie] 03/05: Imported Upstream version 0.1.2

Jérémy Lal kapouer at moszumanska.debian.org
Sun Oct 12 07:25:29 UTC 2014


This is an automated email from the git hooks/post-receive script.

kapouer pushed a commit to branch master
in repository node-cookie.

commit 1a2234986bc8274c750107d319145b6e6a0a749a
Author: Jérémy Lal <kapouer at melix.org>
Date:   Sun Oct 12 09:24:03 2014 +0200

    Imported Upstream version 0.1.2
---
 .npmignore        | 2 ++
 README.md         | 2 +-
 index.js          | 9 +++++++--
 package.json      | 2 +-
 test/parse.js     | 7 +++++++
 test/serialize.js | 4 ++++
 6 files changed, 22 insertions(+), 4 deletions(-)

diff --git a/.npmignore b/.npmignore
new file mode 100644
index 0000000..efab07f
--- /dev/null
+++ b/.npmignore
@@ -0,0 +1,2 @@
+test
+.travis.yml
diff --git a/README.md b/README.md
index 5187ed1..3170b4b 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-# cookie [![Build Status](https://secure.travis-ci.org/shtylman/node-cookie.png?branch=master)](http://travis-ci.org/shtylman/node-cookie) #
+# cookie [![Build Status](https://secure.travis-ci.org/defunctzombie/node-cookie.png?branch=master)](http://travis-ci.org/defunctzombie/node-cookie) #
 
 cookie is a basic cookie parser and serializer. It doesn't make assumptions about how you are going to deal with your cookies. It basically just provides a way to read and write the HTTP cookie headers.
 
diff --git a/index.js b/index.js
index 16bdb65..00d54a7 100644
--- a/index.js
+++ b/index.js
@@ -14,7 +14,12 @@ var serialize = function(name, val, opt){
     var enc = opt.encode || encode;
     var pairs = [name + '=' + enc(val)];
 
-    if (opt.maxAge) pairs.push('Max-Age=' + opt.maxAge);
+    if (null != opt.maxAge) {
+        var maxAge = opt.maxAge - 0;
+        if (isNaN(maxAge)) throw new Error('maxAge should be a Number');
+        pairs.push('Max-Age=' + maxAge);
+    }
+
     if (opt.domain) pairs.push('Domain=' + opt.domain);
     if (opt.path) pairs.push('Path=' + opt.path);
     if (opt.expires) pairs.push('Expires=' + opt.expires.toUTCString());
@@ -31,7 +36,7 @@ var serialize = function(name, val, opt){
 var parse = function(str, opt) {
     opt = opt || {};
     var obj = {}
-    var pairs = str.split(/[;,] */);
+    var pairs = str.split(/; */);
     var dec = opt.decode || decode;
 
     pairs.forEach(function(pair) {
diff --git a/package.json b/package.json
index ee107e1..387dced 100644
--- a/package.json
+++ b/package.json
@@ -2,7 +2,7 @@
   "author": "Roman Shtylman <shtylman at gmail.com>",
   "name": "cookie",
   "description": "cookie parsing and serialization",
-  "version": "0.1.0",
+  "version": "0.1.2",
   "repository": {
     "type": "git",
     "url": "git://github.com/shtylman/node-cookie.git"
diff --git a/test/parse.js b/test/parse.js
index c6c27a2..371941f 100644
--- a/test/parse.js
+++ b/test/parse.js
@@ -41,4 +41,11 @@ test('unencoded', function() {
             cookie.parse('email=%20%22%2c%3b%2f',{
                 decode: function(value) { return value; }
             }));
+});
+
+test('dates', function() {
+    assert.deepEqual({ priority: 'true', Path: '/', expires: 'Wed, 29 Jan 2014 17:43:25 GMT' },
+            cookie.parse('priority=true; expires=Wed, 29 Jan 2014 17:43:25 GMT; Path=/',{
+                decode: function(value) { return value; }
+            }));
 })
diff --git a/test/serialize.js b/test/serialize.js
index 86bb8c9..7939f51 100644
--- a/test/serialize.js
+++ b/test/serialize.js
@@ -42,6 +42,10 @@ test('maxAge', function() {
     assert.equal('foo=bar; Max-Age=1000', cookie.serialize('foo', 'bar', {
         maxAge: 1000
     }));
+
+    assert.equal('foo=bar; Max-Age=0', cookie.serialize('foo', 'bar', {
+        maxAge: 0
+    }));
 });
 
 test('escaping', function() {

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-cookie.git



More information about the Pkg-javascript-commits mailing list