From 0dc95ef2a48d4cdf5e3f34c521b6e19c6958bf52 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sun, 9 Jun 2019 20:41:31 -0400 Subject: [PATCH 001/159] build: Node.js@10.16 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 063cec6..11d1c81 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,7 +13,7 @@ node_js: - "7.10" - "8.16" - "9.11" - - "10.15" + - "10.16" - "11.15" - "12.2" sudo: false From 040fd81bd733975db3a824c9d61a25f6577fdf30 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sun, 9 Jun 2019 20:45:45 -0400 Subject: [PATCH 002/159] build: Node.js@12.4 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 11d1c81..e4e880b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,7 +15,7 @@ node_js: - "9.11" - "10.16" - "11.15" - - "12.2" + - "12.4" sudo: false dist: trusty env: From 8e9c4530b32c5c663248630e567d8958363a2dd6 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 7 Aug 2019 18:59:12 -0400 Subject: [PATCH 003/159] build: mocha@6.2.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9bfbc47..f785cc9 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "eslint": "5.16.0", "eslint-plugin-markdown": "1.0.0", "istanbul": "0.4.5", - "mocha": "6.1.4" + "mocha": "6.2.0" }, "files": [ "HISTORY.md", From a88a7c7e98e9b413b43e6aa96f461911bff531ad Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 7 Aug 2019 19:08:26 -0400 Subject: [PATCH 004/159] build: Node.js@12.8 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index e4e880b..9e499c6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,7 +15,7 @@ node_js: - "9.11" - "10.16" - "11.15" - - "12.4" + - "12.8" sudo: false dist: trusty env: From 19ad684737b069fbdd060cd895dcfee460fde6e2 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 4 Sep 2019 21:33:38 -0400 Subject: [PATCH 005/159] build: eslint@6.3.0 --- .travis.yml | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9e499c6..6cd6599 100644 --- a/.travis.yml +++ b/.travis.yml @@ -68,7 +68,7 @@ before_install: # Setup Node.js version-specific dependencies - | # Configure eslint for linting - if node_version_lt '6.0'; then npm_remove_module_re '^eslint(-|$)' + if node_version_lt '8.0'; then npm_remove_module_re '^eslint(-|$)' fi - | # Configure istanbul for coverage diff --git a/package.json b/package.json index f785cc9..49f0daa 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "devDependencies": { "beautify-benchmark": "0.2.4", "benchmark": "2.1.4", - "eslint": "5.16.0", + "eslint": "6.3.0", "eslint-plugin-markdown": "1.0.0", "istanbul": "0.4.5", "mocha": "6.2.0" From 21ff6330cb9f3ec59f996f4f05830f6ce2498b17 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Fri, 6 Sep 2019 22:09:15 -0400 Subject: [PATCH 006/159] docs: add preamble to install section --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 857fb77..18b2c2c 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,10 @@ Basic HTTP cookie parser and serializer for HTTP servers. ## Installation +This is a [Node.js](https://nodejs.org/en/) module available through the +[npm registry](https://www.npmjs.com/). Installation is done using the +[`npm install` command](https://docs.npmjs.com/getting-started/installing-npm-packages-locally): + ```sh $ npm install cookie ``` From a39d8bc9a4c510be65b306b37559b5c094112ffc Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Fri, 6 Sep 2019 22:12:09 -0400 Subject: [PATCH 007/159] build: Node.js@12.10 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 6cd6599..61bf363 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,7 +15,7 @@ node_js: - "9.11" - "10.16" - "11.15" - - "12.8" + - "12.10" sudo: false dist: trusty env: From 1af5e05a230a096fc897d900fe2f9f9940e212fc Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sun, 8 Dec 2019 20:31:26 -0500 Subject: [PATCH 008/159] build: mocha@6.2.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 49f0daa..3f1334e 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "eslint": "6.3.0", "eslint-plugin-markdown": "1.0.0", "istanbul": "0.4.5", - "mocha": "6.2.0" + "mocha": "6.2.2" }, "files": [ "HISTORY.md", From c1c9c9a854cade211c67cea81f7f6609b80ba4bc Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sun, 8 Dec 2019 20:34:55 -0500 Subject: [PATCH 009/159] build: eslint-plugin-markdown@1.0.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 3f1334e..4706bf5 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "beautify-benchmark": "0.2.4", "benchmark": "2.1.4", "eslint": "6.3.0", - "eslint-plugin-markdown": "1.0.0", + "eslint-plugin-markdown": "1.0.1", "istanbul": "0.4.5", "mocha": "6.2.2" }, From d96a27d966ffd1884c4ace20f49c81f065236f9b Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sun, 8 Dec 2019 20:37:17 -0500 Subject: [PATCH 010/159] build: Node.js@10.17 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 61bf363..cf478ff 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,7 +13,7 @@ node_js: - "7.10" - "8.16" - "9.11" - - "10.16" + - "10.17" - "11.15" - "12.10" sudo: false From 0ed4757ba6a38a3bad27f8ab75c7de822add3af3 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Fri, 13 Dec 2019 23:47:33 -0500 Subject: [PATCH 011/159] build: Node.js@12.13 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index cf478ff..f788d20 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,7 +15,7 @@ node_js: - "9.11" - "10.17" - "11.15" - - "12.10" + - "12.13" sudo: false dist: trusty env: From c4c82389749f9b58795d61d139b1ed395e9af8ef Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sat, 14 Dec 2019 00:03:36 -0500 Subject: [PATCH 012/159] build: support Node.js 13.x --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index f788d20..0865d3a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,6 +16,7 @@ node_js: - "10.17" - "11.15" - "12.13" + - "13.3" sudo: false dist: trusty env: From 79939d6f71099af5c7c4bc7c8ae10597b94d7eef Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sat, 14 Dec 2019 00:09:47 -0500 Subject: [PATCH 013/159] build: eslint@6.7.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4706bf5..919a399 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "devDependencies": { "beautify-benchmark": "0.2.4", "benchmark": "2.1.4", - "eslint": "6.3.0", + "eslint": "6.7.2", "eslint-plugin-markdown": "1.0.1", "istanbul": "0.4.5", "mocha": "6.2.2" From 0b8f5ef0ead8afb3c44ab02bda15dd9598bb7d95 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sat, 28 Dec 2019 21:08:38 -0500 Subject: [PATCH 014/159] build: Node.js@8.17 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 0865d3a..c65e8a1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,7 +11,7 @@ node_js: - "5.12" - "6.17" - "7.10" - - "8.16" + - "8.17" - "9.11" - "10.17" - "11.15" From fe4927972381e468b5f77f0b926542ed046efc45 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 2 Jan 2020 20:03:38 -0500 Subject: [PATCH 015/159] build: Node.js@10.18 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index c65e8a1..d2e9ab2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,7 +13,7 @@ node_js: - "7.10" - "8.17" - "9.11" - - "10.17" + - "10.18" - "11.15" - "12.13" - "13.3" From 3992c294e110df53f3e476cf8b11e44c09b31419 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 2 Jan 2020 20:09:24 -0500 Subject: [PATCH 016/159] build: Node.js@12.14 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index d2e9ab2..a0f8e89 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,7 +15,7 @@ node_js: - "9.11" - "10.18" - "11.15" - - "12.13" + - "12.14" - "13.3" sudo: false dist: trusty From 933780f875193b28e280422d7cd49b04c1634086 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 9 Jan 2020 22:43:57 -0500 Subject: [PATCH 017/159] build: Node.js@13.6 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index a0f8e89..f575dea 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,7 +16,7 @@ node_js: - "10.18" - "11.15" - "12.14" - - "13.3" + - "13.6" sudo: false dist: trusty env: From 54d780e6353f1ecd03311109ba47a1706633f9ec Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 22 Jan 2020 19:20:45 -0500 Subject: [PATCH 018/159] build: eslint@6.8.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 919a399..5f37287 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "devDependencies": { "beautify-benchmark": "0.2.4", "benchmark": "2.1.4", - "eslint": "6.7.2", + "eslint": "6.8.0", "eslint-plugin-markdown": "1.0.1", "istanbul": "0.4.5", "mocha": "6.2.2" From 1c4efa3c224031d0973e28b8ef8aaceae43dcf03 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 22 Jan 2020 19:28:45 -0500 Subject: [PATCH 019/159] build: mocha@7.0.0 --- .travis.yml | 1 + package.json | 8 ++++---- test/mocha.opts | 1 - 3 files changed, 5 insertions(+), 5 deletions(-) delete mode 100644 test/mocha.opts diff --git a/.travis.yml b/.travis.yml index f575dea..d168e45 100644 --- a/.travis.yml +++ b/.travis.yml @@ -81,6 +81,7 @@ before_install: elif node_version_lt '0.10'; then npm_use_module 'mocha' '2.5.3' elif node_version_lt '4.0' ; then npm_use_module 'mocha' '3.5.3' elif node_version_lt '6.0' ; then npm_use_module 'mocha' '5.2.0' + elif node_version_lt '8.0' ; then npm_use_module 'mocha' '6.2.2' fi # Update Node.js modules - | diff --git a/package.json b/package.json index 5f37287..02bf16e 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "eslint": "6.8.0", "eslint-plugin-markdown": "1.0.1", "istanbul": "0.4.5", - "mocha": "6.2.2" + "mocha": "7.0.0" }, "files": [ "HISTORY.md", @@ -32,9 +32,9 @@ "scripts": { "bench": "node benchmark/index.js", "lint": "eslint --plugin markdown --ext js,md .", - "test": "mocha --reporter spec --bail --check-leaks test/", - "test-ci": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/", - "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/", + "test": "mocha --reporter spec --bail --check-leaks --ui qunit test/", + "test-ci": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks --ui qunit test/", + "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks --ui qunit test/", "version": "node scripts/version-history.js && git add HISTORY.md" } } diff --git a/test/mocha.opts b/test/mocha.opts deleted file mode 100644 index e2bfcc5..0000000 --- a/test/mocha.opts +++ /dev/null @@ -1 +0,0 @@ ---ui qunit From 270e1ee7b48fcac22db60b0697ca9a0cf553a4e5 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 12 Feb 2020 20:04:34 -0500 Subject: [PATCH 020/159] build: Node.js@10.19 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index d168e45..b60f72f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,7 +13,7 @@ node_js: - "7.10" - "8.17" - "9.11" - - "10.18" + - "10.19" - "11.15" - "12.14" - "13.6" From ba4b390bc938cebfa34e60733abee542a7cdfb96 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 12 Feb 2020 20:09:42 -0500 Subject: [PATCH 021/159] build: Node.js@12.16 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index b60f72f..a334c16 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,7 +15,7 @@ node_js: - "9.11" - "10.19" - "11.15" - - "12.14" + - "12.16" - "13.6" sudo: false dist: trusty From 8fff98da0bc9f94b0f6340cd449a59aff1506fa6 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 12 Feb 2020 20:12:38 -0500 Subject: [PATCH 022/159] build: Node.js@13.8 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index a334c16..137a3fa 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,7 +16,7 @@ node_js: - "10.19" - "11.15" - "12.16" - - "13.6" + - "13.8" sudo: false dist: trusty env: From 10dddeae7df42afe209916f65f02ef2f0e75ae75 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sun, 8 Mar 2020 19:20:29 -0400 Subject: [PATCH 023/159] build: eslint-plugin-markdown@1.0.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 02bf16e..4d1af94 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "beautify-benchmark": "0.2.4", "benchmark": "2.1.4", "eslint": "6.8.0", - "eslint-plugin-markdown": "1.0.1", + "eslint-plugin-markdown": "1.0.2", "istanbul": "0.4.5", "mocha": "7.0.0" }, From 3cb3ae571583e51cf7088336af9f06b65e05804e Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sun, 8 Mar 2020 19:20:25 -0400 Subject: [PATCH 024/159] build: mocha@7.1.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4d1af94..97e4a18 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "eslint": "6.8.0", "eslint-plugin-markdown": "1.0.2", "istanbul": "0.4.5", - "mocha": "7.0.0" + "mocha": "7.1.0" }, "files": [ "HISTORY.md", From 004b69325beeee18df7155a52886fb7b05bf1af3 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 9 Mar 2020 20:26:44 -0400 Subject: [PATCH 025/159] build: Node.js@13.10 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 137a3fa..be74f31 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,7 +16,7 @@ node_js: - "10.19" - "11.15" - "12.16" - - "13.8" + - "13.10" sudo: false dist: trusty env: From 9b4abbd2fff8da3f319aaf02466eb6bde2ee5642 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sat, 11 Apr 2020 23:41:23 -0400 Subject: [PATCH 026/159] build: mocha@7.1.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 97e4a18..f9f6717 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "eslint": "6.8.0", "eslint-plugin-markdown": "1.0.2", "istanbul": "0.4.5", - "mocha": "7.1.0" + "mocha": "7.1.1" }, "files": [ "HISTORY.md", From cb5746d8f17e7a5b81bf467372a8fee83d244f30 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sat, 11 Apr 2020 23:47:52 -0400 Subject: [PATCH 027/159] build: Node.js@10.20 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index be74f31..8561416 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,7 +13,7 @@ node_js: - "7.10" - "8.17" - "9.11" - - "10.19" + - "10.20" - "11.15" - "12.16" - "13.10" From 7e1398fda5390c6b4281213d47873244d0cd3302 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sat, 11 Apr 2020 23:49:16 -0400 Subject: [PATCH 028/159] build: Node.js@13.12 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 8561416..7f2e6c5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,7 +16,7 @@ node_js: - "10.20" - "11.15" - "12.16" - - "13.10" + - "13.12" sudo: false dist: trusty env: From e248786d0aaab4a4759bd277066e50f38067e402 Mon Sep 17 00:00:00 2001 From: sandip mondal Date: Tue, 14 Apr 2020 16:25:30 +0530 Subject: [PATCH 029/159] Fix maxAge option to reject invalid values fixes #103 closes #104 --- HISTORY.md | 5 +++++ index.js | 6 +++++- test/serialize.js | 8 +++++++- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index da2bf24..1b73fba 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,3 +1,8 @@ +unreleased +========== + + * Fix `maxAge` option to reject invalid values + 0.4.0 / 2019-05-15 ================== diff --git a/index.js b/index.js index 16f56c0..760f32e 100644 --- a/index.js +++ b/index.js @@ -120,7 +120,11 @@ function serialize(name, val, options) { if (null != opt.maxAge) { var maxAge = opt.maxAge - 0; - if (isNaN(maxAge)) throw new Error('maxAge should be a Number'); + + if (isNaN(maxAge) || !isFinite(maxAge)) { + throw new TypeError('option maxAge is invalid') + } + str += '; Max-Age=' + Math.floor(maxAge); } diff --git a/test/serialize.js b/test/serialize.js index ad28bdf..ce3c665 100644 --- a/test/serialize.js +++ b/test/serialize.js @@ -55,7 +55,13 @@ test('maxAge', function() { cookie.serialize('foo', 'bar', { maxAge: 'buzz' }); - }, /maxAge should be a Number/); + }, /option maxAge is invalid/) + + assert.throws(function () { + cookie.serialize('foo', 'bar', { + maxAge: Infinity + }) + }, /option maxAge is invalid/) assert.equal('foo=bar; Max-Age=1000', cookie.serialize('foo', 'bar', { maxAge: 1000 From 80372a472779e63194e282c4d36cc26de2011409 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Tue, 21 Apr 2020 21:17:55 -0400 Subject: [PATCH 030/159] build: remove deprecated Travis CI directive --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 7f2e6c5..e4adec5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,7 +17,6 @@ node_js: - "11.15" - "12.16" - "13.12" -sudo: false dist: trusty env: global: From 08e98eeb621563b865ae40c53929eead14a9485a Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Tue, 21 Apr 2020 21:18:10 -0400 Subject: [PATCH 031/159] build: Node.js@13.13 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index e4adec5..54dabeb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,7 +16,7 @@ node_js: - "10.20" - "11.15" - "12.16" - - "13.12" + - "13.13" dist: trusty env: global: From 2436f3f71904fb56fb74f27d6d940a17e756fc71 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Tue, 21 Apr 2020 21:38:21 -0400 Subject: [PATCH 032/159] build: use nyc for code coverage --- .gitignore | 1 + .travis.yml | 21 ++++++++++++--------- package.json | 8 ++++---- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/.gitignore b/.gitignore index 0fa6951..f15b98e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +.nyc_output/ coverage/ node_modules/ npm-debug.log diff --git a/.travis.yml b/.travis.yml index 54dabeb..3e419e0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -70,10 +70,6 @@ before_install: # Configure eslint for linting if node_version_lt '8.0'; then npm_remove_module_re '^eslint(-|$)' fi - - | - # Configure istanbul for coverage - if node_version_lt '0.10'; then npm_remove_module_re '^istanbul$' - fi - | # Configure mocha for testing if node_version_lt '0.8' ; then npm_use_module 'mocha' '1.21.5' @@ -82,6 +78,13 @@ before_install: elif node_version_lt '6.0' ; then npm_use_module 'mocha' '5.2.0' elif node_version_lt '8.0' ; then npm_use_module 'mocha' '6.2.2' fi + - | + # Configure nyc for testing + if node_version_lt '0.10'; then npm_remove_module_re '^nyc$' + elif node_version_lt '4.0' ; then npm_use_module 'nyc' '10.3.2' + elif node_version_lt '6.0' ; then npm_use_module 'nyc' '11.9.0' + elif node_version_lt '8.0' ; then npm_use_module 'nyc' '14.1.1' + fi # Update Node.js modules - | # Prune & rebuild node_modules @@ -95,8 +98,8 @@ before_scrpt: npm -s ls ||: script: - | - # Run test script, depending on istanbul install - if npm_module_installed 'istanbul'; then npm run-script test-ci + # Run test script, depending on nyc install + if npm_module_installed 'nyc'; then npm run-script test-ci else npm test fi - | @@ -105,8 +108,8 @@ script: fi after_script: - | - # Upload coverage to coveralls if exists - if [[ -e ./coverage/lcov.info ]]; then + # Upload coverage to coveralls + if [[ -d .nyc_output ]]; then npm install --save-dev coveralls@2 - coveralls < ./coverage/lcov.info + nyc report --reporter=text-lcov | coveralls fi diff --git a/package.json b/package.json index f9f6717..1f342e7 100644 --- a/package.json +++ b/package.json @@ -17,8 +17,8 @@ "benchmark": "2.1.4", "eslint": "6.8.0", "eslint-plugin-markdown": "1.0.2", - "istanbul": "0.4.5", - "mocha": "7.1.1" + "mocha": "7.1.1", + "nyc": "15.0.1" }, "files": [ "HISTORY.md", @@ -33,8 +33,8 @@ "bench": "node benchmark/index.js", "lint": "eslint --plugin markdown --ext js,md .", "test": "mocha --reporter spec --bail --check-leaks --ui qunit test/", - "test-ci": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks --ui qunit test/", - "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks --ui qunit test/", + "test-ci": "nyc --reporter=text npm test", + "test-cov": "nyc --reporter=html --reporter=text npm test", "version": "node scripts/version-history.js && git add HISTORY.md" } } From fa5fe95d2c6ad1b69172102ab3e37a269e3eea50 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Tue, 21 Apr 2020 21:38:39 -0400 Subject: [PATCH 033/159] build: fix typo in Travis CI directive --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 3e419e0..2d03de7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -92,7 +92,7 @@ before_install: npm prune npm rebuild fi -before_scrpt: +before_script: - | # Contents of node_modules npm -s ls ||: From b22458dd9f7ca94705fd7ee25780836601b913aa Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Tue, 21 Apr 2020 23:19:37 -0400 Subject: [PATCH 034/159] 0.4.1 --- HISTORY.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index 1b73fba..ce080e0 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,5 +1,5 @@ -unreleased -========== +0.4.1 / 2020-04-21 +================== * Fix `maxAge` option to reject invalid values diff --git a/package.json b/package.json index 1f342e7..1ae8eb6 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "cookie", "description": "HTTP server cookie parsing and serialization", - "version": "0.4.0", + "version": "0.4.1", "author": "Roman Shtylman ", "contributors": [ "Douglas Christopher Wilson " From 899f2c591a7d865adddc2109255a8c27e63054d4 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Tue, 12 May 2020 19:33:04 -0400 Subject: [PATCH 035/159] build: Node.js@13.14 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 2d03de7..7bb60d5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,7 +16,7 @@ node_js: - "10.20" - "11.15" - "12.16" - - "13.13" + - "13.14" dist: trusty env: global: From 850d55fab33b40cb5be3802ec65d13d0bd01ab8f Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Tue, 12 May 2020 19:38:39 -0400 Subject: [PATCH 036/159] build: support Node.js 14.x --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 7bb60d5..034bf2d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,6 +17,7 @@ node_js: - "11.15" - "12.16" - "13.14" + - "14.2" dist: trusty env: global: From f71a032447b0bbacc9b93a96d0a1d1babd7979c9 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Tue, 12 May 2020 19:39:13 -0400 Subject: [PATCH 037/159] build: mocha@7.1.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1ae8eb6..8373aa0 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "benchmark": "2.1.4", "eslint": "6.8.0", "eslint-plugin-markdown": "1.0.2", - "mocha": "7.1.1", + "mocha": "7.1.2", "nyc": "15.0.1" }, "files": [ From fcbc297b87e73c584a92c230974580bf000c5dbd Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 27 May 2020 18:09:38 -0400 Subject: [PATCH 038/159] build: Node.js@12.17 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 034bf2d..a651404 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,7 +15,7 @@ node_js: - "9.11" - "10.20" - "11.15" - - "12.16" + - "12.17" - "13.14" - "14.2" dist: trusty From f56ae46d29fc7394e28c6376c80216575decf6dd Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 8 Jun 2020 20:05:03 -0400 Subject: [PATCH 039/159] build: Node.js@10.21 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index a651404..a783e8a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,7 +13,7 @@ node_js: - "7.10" - "8.17" - "9.11" - - "10.20" + - "10.21" - "11.15" - "12.17" - "13.14" From 9d300ad9367f1a32f1abb963e1012cc067072c98 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 8 Jun 2020 20:07:31 -0400 Subject: [PATCH 040/159] build: Node.js@12.18 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index a783e8a..00cdd3d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,7 +15,7 @@ node_js: - "9.11" - "10.21" - "11.15" - - "12.17" + - "12.18" - "13.14" - "14.2" dist: trusty From cd3d098b13ca7e855c54ae9282a60847df2efd48 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 11 Jun 2020 22:41:33 -0400 Subject: [PATCH 041/159] build: mocha@8.0.1 --- .travis.yml | 1 + package.json | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 00cdd3d..c9ad96d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -78,6 +78,7 @@ before_install: elif node_version_lt '4.0' ; then npm_use_module 'mocha' '3.5.3' elif node_version_lt '6.0' ; then npm_use_module 'mocha' '5.2.0' elif node_version_lt '8.0' ; then npm_use_module 'mocha' '6.2.2' + elif node_version_lt '10.0'; then npm_use_module 'mocha' '7.1.2' fi - | # Configure nyc for testing diff --git a/package.json b/package.json index 8373aa0..2fca9f6 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "benchmark": "2.1.4", "eslint": "6.8.0", "eslint-plugin-markdown": "1.0.2", - "mocha": "7.1.2", + "mocha": "8.0.1", "nyc": "15.0.1" }, "files": [ From 768d2865bbeb28562fc86370d9f7e514308123b8 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 11 Jun 2020 22:48:56 -0400 Subject: [PATCH 042/159] build: nyc@15.1.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2fca9f6..0d8a0ad 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "eslint": "6.8.0", "eslint-plugin-markdown": "1.0.2", "mocha": "8.0.1", - "nyc": "15.0.1" + "nyc": "15.1.0" }, "files": [ "HISTORY.md", From 22accdfad8aa58d6ec7c25fbf3fe8911aab8a6ff Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Tue, 30 Jun 2020 21:43:21 -0400 Subject: [PATCH 043/159] build: eslint@7.3.1 --- .travis.yml | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index c9ad96d..6df7b94 100644 --- a/.travis.yml +++ b/.travis.yml @@ -69,7 +69,7 @@ before_install: # Setup Node.js version-specific dependencies - | # Configure eslint for linting - if node_version_lt '8.0'; then npm_remove_module_re '^eslint(-|$)' + if node_version_lt '10.0'; then npm_remove_module_re '^eslint(-|$)' fi - | # Configure mocha for testing diff --git a/package.json b/package.json index 0d8a0ad..13bde2d 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "devDependencies": { "beautify-benchmark": "0.2.4", "benchmark": "2.1.4", - "eslint": "6.8.0", + "eslint": "7.3.1", "eslint-plugin-markdown": "1.0.2", "mocha": "8.0.1", "nyc": "15.1.0" From 785cc348aa015f5d938a909fff6b9fd04ffcd3ab Mon Sep 17 00:00:00 2001 From: 3imed-jaberi Date: Sun, 5 Jul 2020 00:18:44 +0200 Subject: [PATCH 044/159] build: Node.js@14.5 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 6df7b94..8584547 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,7 +17,7 @@ node_js: - "11.15" - "12.18" - "13.14" - - "14.2" + - "14.5" dist: trusty env: global: From 1183eb90db31daa92b37f299e15691c1eb02894e Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sat, 1 Aug 2020 20:31:36 -0400 Subject: [PATCH 045/159] build: mocha@8.1.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 13bde2d..4e64199 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "benchmark": "2.1.4", "eslint": "7.3.1", "eslint-plugin-markdown": "1.0.2", - "mocha": "8.0.1", + "mocha": "8.1.0", "nyc": "15.1.0" }, "files": [ From adf52cae522840c3ff7ce12a548edc70b6b4eecb Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sat, 8 Aug 2020 17:48:09 -0400 Subject: [PATCH 046/159] build: eslint@7.6.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4e64199..2032319 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "devDependencies": { "beautify-benchmark": "0.2.4", "benchmark": "2.1.4", - "eslint": "7.3.1", + "eslint": "7.6.0", "eslint-plugin-markdown": "1.0.2", "mocha": "8.1.0", "nyc": "15.1.0" From bcdf45decf1d045c85766a2ab45e837b0530820f Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Fri, 14 Aug 2020 23:56:55 -0400 Subject: [PATCH 047/159] build: Node.js@14.8 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 8584547..c39960b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,7 +17,7 @@ node_js: - "11.15" - "12.18" - "13.14" - - "14.5" + - "14.8" dist: trusty env: global: From b8dd56841904617a1c0cd7a8739cc3a1f55edadb Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sat, 15 Aug 2020 00:02:06 -0400 Subject: [PATCH 048/159] build: Node.js@10.22 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index c39960b..22a2a7a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,7 +13,7 @@ node_js: - "7.10" - "8.17" - "9.11" - - "10.21" + - "10.22" - "11.15" - "12.18" - "13.14" From c8f8a0adab163c91fd5facdbf3a1e87b86f66b05 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Fri, 18 Sep 2020 19:38:48 -0400 Subject: [PATCH 049/159] build: mocha@8.1.3 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2032319..01bcb91 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "benchmark": "2.1.4", "eslint": "7.6.0", "eslint-plugin-markdown": "1.0.2", - "mocha": "8.1.0", + "mocha": "8.1.3", "nyc": "15.1.0" }, "files": [ From 614cb14cb154e7dd5d9853707ecae5fef51fd55e Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Fri, 18 Sep 2020 19:41:02 -0400 Subject: [PATCH 050/159] build: eslint@7.9.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 01bcb91..0fcf1a1 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "devDependencies": { "beautify-benchmark": "0.2.4", "benchmark": "2.1.4", - "eslint": "7.6.0", + "eslint": "7.9.0", "eslint-plugin-markdown": "1.0.2", "mocha": "8.1.3", "nyc": "15.1.0" From 79f5bdb5c744c4d28449c82ab69ede9bcc466c49 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Fri, 16 Oct 2020 17:58:04 -0400 Subject: [PATCH 051/159] build: Node.js@14.14 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 22a2a7a..a498e58 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,7 +17,7 @@ node_js: - "11.15" - "12.18" - "13.14" - - "14.8" + - "14.14" dist: trusty env: global: From b5bc8bc11afc12c61508e034f2433254fd6b7871 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sun, 18 Oct 2020 22:05:34 -0400 Subject: [PATCH 052/159] build: Node.js@12.19 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index a498e58..904c2ea 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,7 +15,7 @@ node_js: - "9.11" - "10.22" - "11.15" - - "12.18" + - "12.19" - "13.14" - "14.14" dist: trusty From 41f673aab72f074d16a2c7bed24d07445baba5dd Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 19 Oct 2020 01:32:12 -0400 Subject: [PATCH 053/159] build: Node.js@10.23 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 904c2ea..33205f0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,7 +13,7 @@ node_js: - "7.10" - "8.17" - "9.11" - - "10.22" + - "10.23" - "11.15" - "12.19" - "13.14" From 009cd1232088d884f4ec8c28219550715ebf5754 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 9 Nov 2020 21:44:41 -0500 Subject: [PATCH 054/159] build: support Node.js 15.x --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 33205f0..f0d1464 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,6 +18,7 @@ node_js: - "12.19" - "13.14" - "14.14" + - "15.1" dist: trusty env: global: From dae1456702acdb3f04c5e3cdea34fe81aec61e4f Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 30 Nov 2020 21:59:52 -0500 Subject: [PATCH 055/159] build: eslint@7.14.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0fcf1a1..b8ae78b 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "devDependencies": { "beautify-benchmark": "0.2.4", "benchmark": "2.1.4", - "eslint": "7.9.0", + "eslint": "7.14.0", "eslint-plugin-markdown": "1.0.2", "mocha": "8.1.3", "nyc": "15.1.0" From 8e7109fd52313e920766882cbde83dbf827deb3c Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 3 Dec 2020 21:08:03 -0500 Subject: [PATCH 056/159] build: mocha@8.2.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b8ae78b..26d312c 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "benchmark": "2.1.4", "eslint": "7.14.0", "eslint-plugin-markdown": "1.0.2", - "mocha": "8.1.3", + "mocha": "8.2.1", "nyc": "15.1.0" }, "files": [ From ecfb052fc983e45f0ee57bf4b3dba3a48bbfb3aa Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 14 Dec 2020 23:54:33 -0500 Subject: [PATCH 057/159] build: Node.js@15.8 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index f0d1464..81bb967 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,7 +18,7 @@ node_js: - "12.19" - "13.14" - "14.14" - - "15.1" + - "15.8" dist: trusty env: global: From 577f0376d88bd650459716d34448b7cf350a221b Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Tue, 15 Dec 2020 00:02:30 -0500 Subject: [PATCH 058/159] build: Node.js@14.15 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 81bb967..dda603d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,7 +17,7 @@ node_js: - "11.15" - "12.19" - "13.14" - - "14.14" + - "14.15" - "15.8" dist: trusty env: From be3b45aaf80d87fc87b7e51a1237f825cc722677 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Tue, 15 Dec 2020 00:05:27 -0500 Subject: [PATCH 059/159] build: Node.js@12.20 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index dda603d..a5bbd54 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,7 +15,7 @@ node_js: - "9.11" - "10.23" - "11.15" - - "12.19" + - "12.20" - "13.14" - "14.15" - "15.8" From 6fbfbf554c2a2cb5e1e14e87f5191a38beeda25a Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Fri, 8 Jan 2021 19:48:49 -0500 Subject: [PATCH 060/159] build: eslint@7.17.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 26d312c..200aaab 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "devDependencies": { "beautify-benchmark": "0.2.4", "benchmark": "2.1.4", - "eslint": "7.14.0", + "eslint": "7.17.0", "eslint-plugin-markdown": "1.0.2", "mocha": "8.2.1", "nyc": "15.1.0" From ebf5780d30ff59f33d870648ac804ef7d92b2939 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Tue, 16 Feb 2021 17:38:18 -0500 Subject: [PATCH 061/159] build: mocha@8.3.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 200aaab..2ab66ea 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "benchmark": "2.1.4", "eslint": "7.17.0", "eslint-plugin-markdown": "1.0.2", - "mocha": "8.2.1", + "mocha": "8.3.0", "nyc": "15.1.0" }, "files": [ From 058569da2d3f4e0704d5969056813c14e4be80a2 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 17 Mar 2021 20:44:08 -0400 Subject: [PATCH 062/159] build: Node.js@15.11 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index a5bbd54..d1d8a19 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,7 +18,7 @@ node_js: - "12.20" - "13.14" - "14.15" - - "15.8" + - "15.11" dist: trusty env: global: From 0da652a62b72e9daaa614866e562c57741a02612 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 18 Mar 2021 00:21:46 -0400 Subject: [PATCH 063/159] build: Node.js@14.16 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index d1d8a19..e847168 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,7 +17,7 @@ node_js: - "11.15" - "12.20" - "13.14" - - "14.15" + - "14.16" - "15.11" dist: trusty env: From be9410b3e665e78b09c519ab2bb38dcd3f983e31 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 18 Mar 2021 00:24:25 -0400 Subject: [PATCH 064/159] build: Node.js@12.21 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index e847168..a34839d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,7 +15,7 @@ node_js: - "9.11" - "10.23" - "11.15" - - "12.20" + - "12.21" - "13.14" - "14.16" - "15.11" From 8eead2d8b08bc2c6381a06631958c4c446011c55 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sun, 28 Mar 2021 20:43:44 -0400 Subject: [PATCH 065/159] build: eslint@7.23.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2ab66ea..912b742 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "devDependencies": { "beautify-benchmark": "0.2.4", "benchmark": "2.1.4", - "eslint": "7.17.0", + "eslint": "7.23.0", "eslint-plugin-markdown": "1.0.2", "mocha": "8.3.0", "nyc": "15.1.0" From 2f2dbf4c382ebff112a09f49d1161e0f9afcc997 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 29 Mar 2021 18:48:10 -0400 Subject: [PATCH 066/159] build: mocha@8.3.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 912b742..0f0f19b 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "benchmark": "2.1.4", "eslint": "7.23.0", "eslint-plugin-markdown": "1.0.2", - "mocha": "8.3.0", + "mocha": "8.3.2", "nyc": "15.1.0" }, "files": [ From 21c4f7ddac18e0327be3ec3b802641f2c4f5fb6e Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 8 Apr 2021 19:42:22 -0400 Subject: [PATCH 067/159] build: eslint-plugin-markdown@2.0.1 --- .eslintrc.yml | 7 +++++++ package.json | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/.eslintrc.yml b/.eslintrc.yml index 754db18..44febf6 100644 --- a/.eslintrc.yml +++ b/.eslintrc.yml @@ -1,3 +1,10 @@ +extends: + - plugin:markdown/recommended +plugins: + - markdown +overrides: + - files: '**/*.md' + processor: 'markdown/markdown' rules: eol-last: error indent: ["error", 2, { "SwitchCase": 1 }] diff --git a/package.json b/package.json index 0f0f19b..0b2fa6b 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "beautify-benchmark": "0.2.4", "benchmark": "2.1.4", "eslint": "7.23.0", - "eslint-plugin-markdown": "1.0.2", + "eslint-plugin-markdown": "2.0.1", "mocha": "8.3.2", "nyc": "15.1.0" }, @@ -31,7 +31,7 @@ }, "scripts": { "bench": "node benchmark/index.js", - "lint": "eslint --plugin markdown --ext js,md .", + "lint": "eslint .", "test": "mocha --reporter spec --bail --check-leaks --ui qunit test/", "test-ci": "nyc --reporter=text npm test", "test-cov": "nyc --reporter=html --reporter=text npm test", From e496588f7ae9b175ac27dd47eceec5ad067937c1 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 8 Apr 2021 19:44:08 -0400 Subject: [PATCH 068/159] build: Node.js@10.24 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index a34839d..096a7fe 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,7 +13,7 @@ node_js: - "7.10" - "8.17" - "9.11" - - "10.23" + - "10.24" - "11.15" - "12.21" - "13.14" From e938f7d80deb627d02d6b4945f59119a2fa08fe2 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 8 Apr 2021 19:48:28 -0400 Subject: [PATCH 069/159] build: Node.js@12.22 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 096a7fe..8d254d1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,7 +15,7 @@ node_js: - "9.11" - "10.24" - "11.15" - - "12.21" + - "12.22" - "13.14" - "14.16" - "15.11" From 37534895ba37ea57c4f2a5be958ddbe37aebb254 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 8 Apr 2021 19:52:31 -0400 Subject: [PATCH 070/159] build: Node.js@15.14 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 8d254d1..f49d4d8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,7 +18,7 @@ node_js: - "12.22" - "13.14" - "14.16" - - "15.11" + - "15.14" dist: trusty env: global: From eb95ed7b6b313a7b26705ee111895d2fec311cf7 Mon Sep 17 00:00:00 2001 From: Mohammad MohammadAlian Date: Wed, 3 Feb 2021 19:54:33 +0330 Subject: [PATCH 071/159] build: fix typo in error message closes #121 --- scripts/version-history.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/version-history.js b/scripts/version-history.js index b8a2b0e..c58268a 100644 --- a/scripts/version-history.js +++ b/scripts/version-history.js @@ -16,7 +16,7 @@ if (!MD_HEADER_REGEXP.test(historyFileLines[1])) { } if (!VERSION_PLACEHOLDER_REGEXP.test(historyFileLines[0])) { - console.error('Missing placegolder version in HISTORY.md') + console.error('Missing placeholder version in HISTORY.md') process.exit(1) } From 0b519534a5d0bea176f8422aeb93f7d9fce8d683 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 19 Apr 2021 17:47:42 -0400 Subject: [PATCH 072/159] tests: fix assert call arguments fixes #124 --- test/parse.js | 57 ++++++++++------------ test/serialize.js | 121 ++++++++++++---------------------------------- 2 files changed, 57 insertions(+), 121 deletions(-) diff --git a/test/parse.js b/test/parse.js index a48a12e..f19f3b6 100644 --- a/test/parse.js +++ b/test/parse.js @@ -11,62 +11,55 @@ test('argument validation', function() { }); test('basic', function() { - assert.deepEqual({ foo: 'bar' }, cookie.parse('foo=bar')); - assert.deepEqual({ foo: '123' }, cookie.parse('foo=123')); + assert.deepEqual(cookie.parse('foo=bar'), { foo: 'bar' }) + assert.deepEqual(cookie.parse('foo=123'), { foo: '123' }) }); test('ignore spaces', function() { - assert.deepEqual({ FOO: 'bar', baz: 'raz' }, - cookie.parse('FOO = bar; baz = raz')); + assert.deepEqual(cookie.parse('FOO = bar; baz = raz'), + { FOO: 'bar', baz: 'raz' }) }); test('escaping', function() { - assert.deepEqual({ foo: 'bar=123456789&name=Magic+Mouse' }, - cookie.parse('foo="bar=123456789&name=Magic+Mouse"')); + assert.deepEqual(cookie.parse('foo="bar=123456789&name=Magic+Mouse"'), + { foo: 'bar=123456789&name=Magic+Mouse' }) - assert.deepEqual({ email: ' ",;/' }, - cookie.parse('email=%20%22%2c%3b%2f')); + assert.deepEqual(cookie.parse('email=%20%22%2c%3b%2f'), { email: ' ",;/' }) }); test('ignore escaping error and return original value', function() { - assert.deepEqual({ foo: '%1', bar: 'bar' }, cookie.parse('foo=%1;bar=bar')); + assert.deepEqual(cookie.parse('foo=%1;bar=bar'), { foo: '%1', bar: 'bar' }) }); test('ignore non values', function() { - assert.deepEqual({ foo: '%1', bar: 'bar' }, cookie.parse('foo=%1;bar=bar;HttpOnly;Secure')); + assert.deepEqual(cookie.parse('foo=%1;bar=bar;HttpOnly;Secure'), + { foo: '%1', bar: 'bar' }) }); test('unencoded', function() { - assert.deepEqual({ foo: 'bar=123456789&name=Magic+Mouse' }, - cookie.parse('foo="bar=123456789&name=Magic+Mouse"',{ - decode: function(value) { return value; } - })); + assert.deepEqual(cookie.parse('foo="bar=123456789&name=Magic+Mouse"', { + decode: function (v) { return v } + }), { foo: 'bar=123456789&name=Magic+Mouse' }) - assert.deepEqual({ email: '%20%22%2c%3b%2f' }, - cookie.parse('email=%20%22%2c%3b%2f',{ - decode: function(value) { return value; } - })); + assert.deepEqual(cookie.parse('email=%20%22%2c%3b%2f', { + decode: function (v) { return v } + }), { email: '%20%22%2c%3b%2f' }) }); 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; } - })); + assert.deepEqual(cookie.parse('priority=true; expires=Wed, 29 Jan 2014 17:43:25 GMT; Path=/', { + decode: function (v) { return v } + }), { priority: 'true', Path: '/', expires: 'Wed, 29 Jan 2014 17:43:25 GMT' }) }); test('missing value', function() { - assert.deepEqual({ bar: '1', fizz: '', buzz: '2' }, - cookie.parse('foo; bar=1; fizz= ; buzz=2',{ - decode: function(value) { return value; } - })); + assert.deepEqual(cookie.parse('foo; bar=1; fizz= ; buzz=2', { + decode: function (v) { return v } + }), { bar: '1', fizz: '', buzz: '2' }) }); test('assign only once', function() { - assert.deepEqual({ foo: '%1', bar: 'bar' }, - cookie.parse('foo=%1;bar=bar;foo=boo')); - assert.deepEqual({ foo: 'false', bar: 'bar' }, - cookie.parse('foo=false;bar=bar;foo=true')); - assert.deepEqual({ foo: '', bar: 'bar' }, - cookie.parse('foo=;bar=bar;foo=boo')); + assert.deepEqual(cookie.parse('foo=%1;bar=bar;foo=boo'), { foo: '%1', bar: 'bar' }) + assert.deepEqual(cookie.parse('foo=false;bar=bar;foo=true'), { foo: 'false', bar: 'bar' }) + assert.deepEqual(cookie.parse('foo=;bar=bar;foo=boo'), { foo: '', bar: 'bar' }) }); diff --git a/test/serialize.js b/test/serialize.js index ce3c665..92bbb7e 100644 --- a/test/serialize.js +++ b/test/serialize.js @@ -6,48 +6,35 @@ var cookie = require('..'); suite('serialize'); test('basic', function() { - assert.equal('foo=bar', cookie.serialize('foo', 'bar')); - assert.equal('foo=bar%20baz', cookie.serialize('foo', 'bar baz')); - assert.equal('foo=', cookie.serialize('foo', '')); + assert.equal(cookie.serialize('foo', 'bar'), 'foo=bar') + assert.equal(cookie.serialize('foo', 'bar baz'), 'foo=bar%20baz') + assert.equal(cookie.serialize('foo', ''), 'foo=') assert.throws(cookie.serialize.bind(cookie, 'foo\n', 'bar'), /argument name is invalid/); assert.throws(cookie.serialize.bind(cookie, 'foo\u280a', 'bar'), /argument name is invalid/); assert.throws(cookie.serialize.bind(cookie, 'foo', 'bar', {encode: 42}), /option encode is invalid/); }); test('path', function() { - assert.equal('foo=bar; Path=/', cookie.serialize('foo', 'bar', { - path: '/' - })); - + assert.equal(cookie.serialize('foo', 'bar', { path: '/' }), 'foo=bar; Path=/') assert.throws(cookie.serialize.bind(cookie, 'foo', 'bar', { path: '/\n' }), /option path is invalid/); }); test('secure', function() { - assert.equal('foo=bar; Secure', cookie.serialize('foo', 'bar', { - secure: true - })); - - assert.equal('foo=bar', cookie.serialize('foo', 'bar', { - secure: false - })); + assert.equal(cookie.serialize('foo', 'bar', { secure: true }), 'foo=bar; Secure') + assert.equal(cookie.serialize('foo', 'bar', { secure: false }), 'foo=bar') }); test('domain', function() { - assert.equal('foo=bar; Domain=example.com', cookie.serialize('foo', 'bar', { - domain: 'example.com' - })); - + assert.equal(cookie.serialize('foo', 'bar', { domain: 'example.com' }), 'foo=bar; Domain=example.com') assert.throws(cookie.serialize.bind(cookie, 'foo', 'bar', { domain: 'example.com\n' }), /option domain is invalid/); }); test('httpOnly', function() { - assert.equal('foo=bar; HttpOnly', cookie.serialize('foo', 'bar', { - httpOnly: true - })); + assert.equal(cookie.serialize('foo', 'bar', { httpOnly: true }), 'foo=bar; HttpOnly') }); test('maxAge', function() { @@ -63,39 +50,19 @@ test('maxAge', function() { }) }, /option maxAge is invalid/) - assert.equal('foo=bar; Max-Age=1000', cookie.serialize('foo', 'bar', { - maxAge: 1000 - })); - - 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 - })); - - assert.equal('foo=bar; Max-Age=0', cookie.serialize('foo', 'bar', { - maxAge: '0' - })); - - assert.equal('foo=bar', cookie.serialize('foo', 'bar', { - maxAge: null - })); - - assert.equal('foo=bar', cookie.serialize('foo', 'bar', { - maxAge: undefined - })); - - assert.equal('foo=bar; Max-Age=3', cookie.serialize('foo', 'bar', { - maxAge: 3.14 - })); + assert.equal(cookie.serialize('foo', 'bar', { maxAge: 1000 }), 'foo=bar; Max-Age=1000') + assert.equal(cookie.serialize('foo', 'bar', { maxAge: '1000' }), 'foo=bar; Max-Age=1000') + assert.equal(cookie.serialize('foo', 'bar', { maxAge: 0 }), 'foo=bar; Max-Age=0') + assert.equal(cookie.serialize('foo', 'bar', { maxAge: '0' }), 'foo=bar; Max-Age=0') + assert.equal(cookie.serialize('foo', 'bar', { maxAge: null }), 'foo=bar') + assert.equal(cookie.serialize('foo', 'bar', { maxAge: undefined }), 'foo=bar') + assert.equal(cookie.serialize('foo', 'bar', { maxAge: 3.14 }), 'foo=bar; Max-Age=3') }); test('expires', function() { - assert.equal('foo=bar; Expires=Sun, 24 Dec 2000 10:30:59 GMT', cookie.serialize('foo', 'bar', { + assert.equal(cookie.serialize('foo', 'bar', { expires: new Date(Date.UTC(2000, 11, 24, 10, 30, 59, 900)) - })); + }), 'foo=bar; Expires=Sun, 24 Dec 2000 10:30:59 GMT') assert.throws(cookie.serialize.bind(cookie, 'foo', 'bar', { expires: Date.now() @@ -103,37 +70,14 @@ test('expires', function() { }); test('sameSite', function() { - assert.equal('foo=bar; SameSite=Strict', cookie.serialize('foo', 'bar', { - sameSite: true - })); - - assert.equal('foo=bar; SameSite=Strict', cookie.serialize('foo', 'bar', { - sameSite: 'Strict' - })); - - assert.equal('foo=bar; SameSite=Strict', cookie.serialize('foo', 'bar', { - sameSite: 'strict' - })); - - assert.equal('foo=bar; SameSite=Lax', cookie.serialize('foo', 'bar', { - sameSite: 'Lax' - })); - - assert.equal('foo=bar; SameSite=Lax', cookie.serialize('foo', 'bar', { - sameSite: 'lax' - })); - - assert.equal('foo=bar; SameSite=None', cookie.serialize('foo', 'bar', { - sameSite: 'None' - })); - - assert.equal('foo=bar; SameSite=None', cookie.serialize('foo', 'bar', { - sameSite: 'none' - })); - - assert.equal('foo=bar', cookie.serialize('foo', 'bar', { - sameSite: false - })); + assert.equal(cookie.serialize('foo', 'bar', { sameSite: true }), 'foo=bar; SameSite=Strict') + assert.equal(cookie.serialize('foo', 'bar', { sameSite: 'Strict' }), 'foo=bar; SameSite=Strict') + assert.equal(cookie.serialize('foo', 'bar', { sameSite: 'strict' }), 'foo=bar; SameSite=Strict') + assert.equal(cookie.serialize('foo', 'bar', { sameSite: 'Lax' }), 'foo=bar; SameSite=Lax') + assert.equal(cookie.serialize('foo', 'bar', { sameSite: 'lax' }), 'foo=bar; SameSite=Lax') + assert.equal(cookie.serialize('foo', 'bar', { sameSite: 'None' }), 'foo=bar; SameSite=None') + assert.equal(cookie.serialize('foo', 'bar', { sameSite: 'none' }), 'foo=bar; SameSite=None') + assert.equal(cookie.serialize('foo', 'bar', { sameSite: false }), 'foo=bar') assert.throws(cookie.serialize.bind(cookie, 'foo', 'bar', { sameSite: 'foo' @@ -141,22 +85,21 @@ test('sameSite', function() { }); test('escaping', function() { - assert.deepEqual('cat=%2B%20', cookie.serialize('cat', '+ ')); + assert.deepEqual(cookie.serialize('cat', '+ '), 'cat=%2B%20') }); test('parse->serialize', function() { + assert.deepEqual(cookie.parse(cookie.serialize('cat', 'foo=123&name=baz five')), + { cat: 'foo=123&name=baz five' }) - assert.deepEqual({ cat: 'foo=123&name=baz five' }, cookie.parse( - cookie.serialize('cat', 'foo=123&name=baz five'))); - - assert.deepEqual({ cat: ' ";/' }, cookie.parse( - cookie.serialize('cat', ' ";/'))); + assert.deepEqual(cookie.parse(cookie.serialize('cat', ' ";/')), + { cat: ' ";/' }) }); test('unencoded', function() { - assert.deepEqual('cat=+ ', cookie.serialize('cat', '+ ', { + assert.deepEqual(cookie.serialize('cat', '+ ', { encode: function(value) { return value; } - })); + }), 'cat=+ ') assert.throws(cookie.serialize.bind(cookie, 'cat', '+ \n', { encode: function(value) { return value; } From 8807d8138b098f96a35f9f8582f559c59a119228 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 1 Dec 2021 23:41:25 -0500 Subject: [PATCH 073/159] build: use GitHub Actions instead of Travis CI --- .github/workflows/ci.yml | 200 +++++++++++++++++++++++++++++++++++++++ .travis.yml | 118 ----------------------- README.md | 6 +- package.json | 2 +- 4 files changed, 204 insertions(+), 122 deletions(-) create mode 100644 .github/workflows/ci.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..a16bfd0 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,200 @@ +name: ci + +on: +- pull_request +- push + +jobs: + test: + runs-on: ubuntu-18.04 + strategy: + matrix: + name: + - Node.js 0.6 + - Node.js 0.8 + - Node.js 0.10 + - Node.js 0.12 + - io.js 1.x + - io.js 2.x + - io.js 3.x + - Node.js 4.x + - Node.js 5.x + - Node.js 6.x + - Node.js 7.x + - Node.js 8.x + - Node.js 9.x + - Node.js 10.x + - Node.js 11.x + - Node.js 12.x + - Node.js 13.x + - Node.js 14.x + - Node.js 15.x + + include: + - name: Node.js 0.6 + node-version: "0.6" + npm-i: mocha@1.21.5 + npm-rm: beautify-benchmark benchmark nyc + + - name: Node.js 0.8 + node-version: "0.8" + npm-i: mocha@2.5.3 + npm-rm: beautify-benchmark benchmark nyc + + - name: Node.js 0.10 + node-version: "0.10" + npm-i: mocha@3.5.3 nyc@10.3.2 + npm-rm: beautify-benchmark benchmark + + - name: Node.js 0.12 + node-version: "0.12" + npm-i: mocha@3.5.3 nyc@10.3.2 + npm-rm: beautify-benchmark benchmark + + - name: io.js 1.x + node-version: "1.8" + npm-i: mocha@3.5.3 nyc@10.3.2 + npm-rm: beautify-benchmark benchmark + + - name: io.js 2.x + node-version: "2.5" + npm-i: mocha@3.5.3 nyc@10.3.2 + npm-rm: beautify-benchmark benchmark + + - name: io.js 3.x + node-version: "3.3" + npm-i: mocha@3.5.3 nyc@10.3.2 + npm-rm: beautify-benchmark benchmark + + - name: Node.js 4.x + node-version: "4.9" + npm-i: mocha@5.2.0 nyc@11.9.0 + + - name: Node.js 5.x + node-version: "5.12" + npm-i: mocha@5.2.0 nyc@11.9.0 + + - name: Node.js 6.x + node-version: "6.17" + npm-i: mocha@6.2.2 nyc@14.1.1 + + - name: Node.js 7.x + node-version: "7.10" + npm-i: mocha@6.2.2 nyc@14.1.1 + + - name: Node.js 8.x + node-version: "8.17" + npm-i: mocha@7.1.2 + + - name: Node.js 9.x + node-version: "9.11" + npm-i: mocha@7.1.2 + + - name: Node.js 10.x + node-version: "10.24" + + - name: Node.js 11.x + node-version: "11.15" + + - name: Node.js 12.x + node-version: "12.22" + + - name: Node.js 13.x + node-version: "13.14" + + - name: Node.js 14.x + node-version: "14.16" + + - name: Node.js 15.x + node-version: "15.14" + + steps: + - uses: actions/checkout@v2 + + - name: Install Node.js ${{ matrix.node-version }} + shell: bash -eo pipefail -l {0} + run: | + if [[ "${{ matrix.node-version }}" == 0.6* ]]; then + sudo apt-get install g++-4.8 gcc-4.8 libssl1.0-dev + export CC=/usr/bin/gcc-4.8 + export CXX=/usr/bin/g++-4.8 + fi + nvm install --default ${{ matrix.node-version }} + if [[ "${{ matrix.node-version }}" == 0.* && "$(cut -d. -f2 <<< "${{ matrix.node-version }}")" -lt 10 ]]; then + nvm install --alias=npm 0.10 + nvm use ${{ matrix.node-version }} + if [[ "$(npm -v)" == 1.1.* ]]; then + nvm exec npm npm install -g npm@1.1 + ln -fs "$(which npm)" "$(dirname "$(nvm which npm)")/npm" + else + sed -i '1s;^.*$;'"$(printf '#!%q' "$(nvm which npm)")"';' "$(readlink -f "$(which npm)")" + fi + npm config set strict-ssl false + fi + dirname "$(nvm which ${{ matrix.node-version }})" >> "$GITHUB_PATH" + + - name: Configure npm + run: npm config set shrinkwrap false + + - name: Remove npm module(s) ${{ matrix.npm-rm }} + run: npm rm --silent --save-dev ${{ matrix.npm-rm }} + if: matrix.npm-rm != '' + + - name: Install npm module(s) ${{ matrix.npm-i }} + run: npm install --save-dev ${{ matrix.npm-i }} + if: matrix.npm-i != '' + + - name: Setup Node.js version-specific dependencies + shell: bash + run: | + # eslint for linting + # - remove on Node.js < 10 + if [[ "$(cut -d. -f1 <<< "${{ matrix.node-version }}")" -lt 10 ]]; then + node -pe 'Object.keys(require("./package").devDependencies).join("\n")' | \ + grep -E '^eslint(-|$)' | \ + sort -r | \ + xargs -n1 npm rm --silent --save-dev + fi + + - name: Install Node.js dependencies + run: npm install + + - name: List environment + id: list_env + shell: bash + run: | + echo "node@$(node -v)" + echo "npm@$(npm -v)" + npm -s ls ||: + (npm -s ls --depth=0 ||:) | awk -F'[ @]' 'NR>1 && $2 { print "::set-output name=" $2 "::" $3 }' + + - name: Run tests + shell: bash + run: | + if npm -ps ls nyc | grep -q nyc; then + npm run test-ci + else + npm test + fi + + - name: Lint code + if: steps.list_env.outputs.eslint != '' + run: npm run lint + + - name: Collect code coverage + uses: coverallsapp/github-action@master + if: steps.list_env.outputs.nyc != '' + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + flag-name: run-${{ matrix.test_number }} + parallel: true + + coverage: + needs: test + runs-on: ubuntu-latest + steps: + - name: Upload code coverage + uses: coverallsapp/github-action@master + with: + github-token: ${{ secrets.github_token }} + parallel-finished: true diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index f49d4d8..0000000 --- a/.travis.yml +++ /dev/null @@ -1,118 +0,0 @@ -language: node_js -node_js: - - "0.6" - - "0.8" - - "0.10" - - "0.12" - - "1.8" - - "2.5" - - "3.3" - - "4.9" - - "5.12" - - "6.17" - - "7.10" - - "8.17" - - "9.11" - - "10.24" - - "11.15" - - "12.22" - - "13.14" - - "14.16" - - "15.14" -dist: trusty -env: - global: - # Suppress Node.js 0.6 compile warnings - - "CXXCOM='$CXX -o $TARGET -c $CXXFLAGS $CCFLAGS -Wno-unused-local-typedefs -Wno-maybe-uninitialized -Wno-narrowing -Wno-strict-overflow $_CCCOMCOM $SOURCES'" -cache: - directories: - - node_modules -before_install: - - | - # Setup utility functions - function node_version_lt () { - [[ "$(v "$TRAVIS_NODE_VERSION")" -lt "$(v "${1}")" ]] - } - function npm_module_installed () { - npm -lsp ls | grep -Fq "$(pwd)/node_modules/${1}:${1}@" - } - function npm_remove_module_re () { - node -e ' - fs = require("fs"); - p = JSON.parse(fs.readFileSync("package.json", "utf8")); - r = RegExp(process.argv[1]); - for (k in p.devDependencies) { - if (r.test(k)) delete p.devDependencies[k]; - } - fs.writeFileSync("package.json", JSON.stringify(p, null, 2) + "\n"); - ' "$@" - } - function npm_use_module () { - node -e ' - fs = require("fs"); - p = JSON.parse(fs.readFileSync("package.json", "utf8")); - p.devDependencies[process.argv[1]] = process.argv[2]; - fs.writeFileSync("package.json", JSON.stringify(p, null, 2) + "\n"); - ' "$@" - } - function v () { - tr '.' '\n' <<< "${1}" \ - | awk '{ printf "%03d", $0 }' \ - | sed 's/^0*//' - } - # Configure npm - - | - # Skip updating shrinkwrap / lock - npm config set shrinkwrap false - - | - # Remove benchmark dependencies - npm_remove_module_re '(^|-)benchmark$' - # Setup Node.js version-specific dependencies - - | - # Configure eslint for linting - if node_version_lt '10.0'; then npm_remove_module_re '^eslint(-|$)' - fi - - | - # Configure mocha for testing - if node_version_lt '0.8' ; then npm_use_module 'mocha' '1.21.5' - elif node_version_lt '0.10'; then npm_use_module 'mocha' '2.5.3' - elif node_version_lt '4.0' ; then npm_use_module 'mocha' '3.5.3' - elif node_version_lt '6.0' ; then npm_use_module 'mocha' '5.2.0' - elif node_version_lt '8.0' ; then npm_use_module 'mocha' '6.2.2' - elif node_version_lt '10.0'; then npm_use_module 'mocha' '7.1.2' - fi - - | - # Configure nyc for testing - if node_version_lt '0.10'; then npm_remove_module_re '^nyc$' - elif node_version_lt '4.0' ; then npm_use_module 'nyc' '10.3.2' - elif node_version_lt '6.0' ; then npm_use_module 'nyc' '11.9.0' - elif node_version_lt '8.0' ; then npm_use_module 'nyc' '14.1.1' - fi - # Update Node.js modules - - | - # Prune & rebuild node_modules - if [[ -d node_modules ]]; then - npm prune - npm rebuild - fi -before_script: - - | - # Contents of node_modules - npm -s ls ||: -script: - - | - # Run test script, depending on nyc install - if npm_module_installed 'nyc'; then npm run-script test-ci - else npm test - fi - - | - # Run linting, if eslint exists - if npm_module_installed 'eslint'; then npm run-script lint - fi -after_script: - - | - # Upload coverage to coveralls - if [[ -d .nyc_output ]]; then - npm install --save-dev coveralls@2 - nyc report --reporter=text-lcov | coveralls - fi diff --git a/README.md b/README.md index 18b2c2c..665195b 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ [![NPM Version][npm-version-image]][npm-url] [![NPM Downloads][npm-downloads-image]][npm-url] [![Node.js Version][node-version-image]][node-version-url] -[![Build Status][travis-image]][travis-url] +[![Build Status][github-actions-ci-image]][github-actions-ci-url] [![Test Coverage][coveralls-image]][coveralls-url] Basic HTTP cookie parser and serializer for HTTP servers. @@ -248,10 +248,10 @@ $ npm run bench [coveralls-image]: https://badgen.net/coveralls/c/github/jshttp/cookie/master [coveralls-url]: https://coveralls.io/r/jshttp/cookie?branch=master +[github-actions-ci-image]: https://img.shields.io/github/workflow/status/jshttp/cookie/ci/master?label=ci +[github-actions-ci-url]: https://github.com/jshttp/cookie/actions/workflows/ci.yml [node-version-image]: https://badgen.net/npm/node/cookie [node-version-url]: https://nodejs.org/en/download [npm-downloads-image]: https://badgen.net/npm/dm/cookie [npm-url]: https://npmjs.org/package/cookie [npm-version-image]: https://badgen.net/npm/v/cookie -[travis-image]: https://badgen.net/travis/jshttp/cookie/master -[travis-url]: https://travis-ci.org/jshttp/cookie diff --git a/package.json b/package.json index 0b2fa6b..42c4940 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ "bench": "node benchmark/index.js", "lint": "eslint .", "test": "mocha --reporter spec --bail --check-leaks --ui qunit test/", - "test-ci": "nyc --reporter=text npm test", + "test-ci": "nyc --reporter=lcov --reporter=text npm test", "test-cov": "nyc --reporter=html --reporter=text npm test", "version": "node scripts/version-history.js && git add HISTORY.md" } From 252d1d95786158534515f2d9c1f488cf5b95100b Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sun, 5 Dec 2021 16:58:43 -0500 Subject: [PATCH 074/159] build: eslint@7.32.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 42c4940..4ac519e 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "devDependencies": { "beautify-benchmark": "0.2.4", "benchmark": "2.1.4", - "eslint": "7.23.0", + "eslint": "7.32.0", "eslint-plugin-markdown": "2.0.1", "mocha": "8.3.2", "nyc": "15.1.0" From 4f2c41b0017f1f09932321b1e05f13044103cb1c Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Fri, 24 Dec 2021 22:54:00 -0500 Subject: [PATCH 075/159] build: support Node.js 16.x --- .github/workflows/ci.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a16bfd0..f561a5c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,6 +29,7 @@ jobs: - Node.js 13.x - Node.js 14.x - Node.js 15.x + - Node.js 16.x include: - name: Node.js 0.6 @@ -108,6 +109,9 @@ jobs: - name: Node.js 15.x node-version: "15.14" + - name: Node.js 16.x + node-version: "16.13" + steps: - uses: actions/checkout@v2 From 4e9cb8801e4a89706e69450ad64c59a4cf578cd5 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Fri, 24 Dec 2021 22:58:12 -0500 Subject: [PATCH 076/159] build: eslint-plugin-markdown@2.2.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4ac519e..0fb4631 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "beautify-benchmark": "0.2.4", "benchmark": "2.1.4", "eslint": "7.32.0", - "eslint-plugin-markdown": "2.0.1", + "eslint-plugin-markdown": "2.2.1", "mocha": "8.3.2", "nyc": "15.1.0" }, From 03fcbbe3301ad2db9d832d25688577f8542e91af Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 5 Jan 2022 18:33:19 -0500 Subject: [PATCH 077/159] build: Node.js@14.18 --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f561a5c..9f56ebc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -104,7 +104,7 @@ jobs: node-version: "13.14" - name: Node.js 14.x - node-version: "14.16" + node-version: "14.18" - name: Node.js 15.x node-version: "15.14" From 41b5ac17638ad8d4b71add639b58632ca2bb6d3e Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 5 Jan 2022 18:34:47 -0500 Subject: [PATCH 078/159] build: mocha@8.4.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0fb4631..56e5d47 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "benchmark": "2.1.4", "eslint": "7.32.0", "eslint-plugin-markdown": "2.2.1", - "mocha": "8.3.2", + "mocha": "8.4.0", "nyc": "15.1.0" }, "files": [ From b31ed443e3d69a03c8ce0705f1f5695770c0ae4c Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Tue, 18 Jan 2022 21:12:35 -0500 Subject: [PATCH 079/159] build: support Node.js 17.x --- .github/workflows/ci.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9f56ebc..00c5db7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -30,6 +30,7 @@ jobs: - Node.js 14.x - Node.js 15.x - Node.js 16.x + - Node.js 17.x include: - name: Node.js 0.6 @@ -112,6 +113,9 @@ jobs: - name: Node.js 16.x node-version: "16.13" + - name: Node.js 17.x + node-version: "17.4" + steps: - uses: actions/checkout@v2 From f05635629b08e9d0b66c7c0177c649fe13cbd6ed Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Tue, 18 Jan 2022 21:13:47 -0500 Subject: [PATCH 080/159] build: mocha@9.1.4 --- .github/workflows/ci.yml | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 00c5db7..b262365 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -94,9 +94,11 @@ jobs: - name: Node.js 10.x node-version: "10.24" + npm-i: mocha@8.4.0 - name: Node.js 11.x node-version: "11.15" + npm-i: mocha@8.4.0 - name: Node.js 12.x node-version: "12.22" diff --git a/package.json b/package.json index 56e5d47..5d96205 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "benchmark": "2.1.4", "eslint": "7.32.0", "eslint-plugin-markdown": "2.2.1", - "mocha": "8.4.0", + "mocha": "9.1.4", "nyc": "15.1.0" }, "files": [ From 4f08c953daba17127ddc7bcb5fd95c20b9d80d13 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Tue, 18 Jan 2022 22:14:14 -0500 Subject: [PATCH 081/159] docs: update benchmark --- README.md | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 665195b..b25446c 100644 --- a/README.md +++ b/README.md @@ -198,19 +198,26 @@ $ npm test ``` $ npm run bench -> cookie@0.3.1 bench cookie +> cookie@0.4.1 bench > node benchmark/index.js - http_parser@2.8.0 - node@6.14.2 - v8@5.1.281.111 - uv@1.16.1 + node@16.13.1 + v8@9.4.146.24-node.14 + uv@1.42.0 zlib@1.2.11 - ares@1.10.1-DEV - icu@58.2 - modules@48 - napi@3 - openssl@1.0.2o + brotli@1.0.9 + ares@1.18.1 + modules@93 + nghttp2@1.45.1 + napi@8 + llhttp@6.0.4 + openssl@1.1.1l+quic + cldr@39.0 + icu@69.1 + tz@2021a + unicode@13.0 + ngtcp2@0.1.0-DEV + nghttp3@0.1.0-DEV > node benchmark/parse.js @@ -218,12 +225,12 @@ $ npm run bench 6 tests completed. - simple x 1,200,691 ops/sec ±1.12% (189 runs sampled) - decode x 1,012,994 ops/sec ±0.97% (186 runs sampled) - unquote x 1,074,174 ops/sec ±2.43% (186 runs sampled) - duplicates x 438,424 ops/sec ±2.17% (184 runs sampled) - 10 cookies x 147,154 ops/sec ±1.01% (186 runs sampled) - 100 cookies x 14,274 ops/sec ±1.07% (187 runs sampled) + simple x 1,583,012 ops/sec ±0.70% (191 runs sampled) + decode x 958,910 ops/sec ±0.44% (193 runs sampled) + unquote x 974,390 ops/sec ±4.49% (188 runs sampled) + duplicates x 572,274 ops/sec ±0.55% (190 runs sampled) + 10 cookies x 164,955 ops/sec ±0.69% (186 runs sampled) + 100 cookies x 15,415 ops/sec ±0.57% (193 runs sampled) ``` ## References From 2bcee5a742434cdc333d5c898bf64d79de90c557 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Tue, 18 Jan 2022 22:40:15 -0500 Subject: [PATCH 082/159] bench: add cookies from top 20 sites closes #79 --- .github/workflows/ci.yml | 20 +++++++---- README.md | 36 ++++++++++++++++---- benchmark/parse-top.js | 47 ++++++++++++++++++++++++++ benchmark/parse-top.json | 17 ++++++++++ benchmark/parse.js | 2 +- package.json | 4 ++- scripts/update-benchmark.js | 66 +++++++++++++++++++++++++++++++++++++ 7 files changed, 176 insertions(+), 16 deletions(-) create mode 100644 benchmark/parse-top.js create mode 100644 benchmark/parse-top.json create mode 100644 scripts/update-benchmark.js diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b262365..b29acae 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -36,61 +36,67 @@ jobs: - name: Node.js 0.6 node-version: "0.6" npm-i: mocha@1.21.5 - npm-rm: beautify-benchmark benchmark nyc + npm-rm: beautify-benchmark benchmark nyc top-sites - name: Node.js 0.8 node-version: "0.8" npm-i: mocha@2.5.3 - npm-rm: beautify-benchmark benchmark nyc + npm-rm: beautify-benchmark benchmark nyc top-sites - name: Node.js 0.10 node-version: "0.10" npm-i: mocha@3.5.3 nyc@10.3.2 - npm-rm: beautify-benchmark benchmark + npm-rm: beautify-benchmark benchmark top-sites - name: Node.js 0.12 node-version: "0.12" npm-i: mocha@3.5.3 nyc@10.3.2 - npm-rm: beautify-benchmark benchmark + npm-rm: beautify-benchmark benchmark top-sites - name: io.js 1.x node-version: "1.8" npm-i: mocha@3.5.3 nyc@10.3.2 - npm-rm: beautify-benchmark benchmark + npm-rm: beautify-benchmark benchmark top-sites - name: io.js 2.x node-version: "2.5" npm-i: mocha@3.5.3 nyc@10.3.2 - npm-rm: beautify-benchmark benchmark + npm-rm: beautify-benchmark benchmark top-sites - name: io.js 3.x node-version: "3.3" npm-i: mocha@3.5.3 nyc@10.3.2 - npm-rm: beautify-benchmark benchmark + npm-rm: beautify-benchmark benchmark top-sites - name: Node.js 4.x node-version: "4.9" npm-i: mocha@5.2.0 nyc@11.9.0 + npm-rm: beautify-benchmark benchmark top-sites - name: Node.js 5.x node-version: "5.12" npm-i: mocha@5.2.0 nyc@11.9.0 + npm-rm: beautify-benchmark benchmark top-sites - name: Node.js 6.x node-version: "6.17" npm-i: mocha@6.2.2 nyc@14.1.1 + npm-rm: beautify-benchmark benchmark top-sites - name: Node.js 7.x node-version: "7.10" npm-i: mocha@6.2.2 nyc@14.1.1 + npm-rm: beautify-benchmark benchmark top-sites - name: Node.js 8.x node-version: "8.17" npm-i: mocha@7.1.2 + npm-rm: beautify-benchmark benchmark top-sites - name: Node.js 9.x node-version: "9.11" npm-i: mocha@7.1.2 + npm-rm: beautify-benchmark benchmark top-sites - name: Node.js 10.x node-version: "10.24" diff --git a/README.md b/README.md index b25446c..602fd17 100644 --- a/README.md +++ b/README.md @@ -219,18 +219,40 @@ $ npm run bench ngtcp2@0.1.0-DEV nghttp3@0.1.0-DEV +> node benchmark/parse-top.js + + cookie.parse - top sites + + 15 tests completed. + + parse accounts.google.com x 522,610 ops/sec ±7.53% (191 runs sampled) + parse apple.com x 1,617,049 ops/sec ±12.52% (173 runs sampled) + parse cloudflare.com x 379,557 ops/sec ±3.46% (189 runs sampled) + parse docs.google.com x 603,625 ops/sec ±1.33% (189 runs sampled) + parse drive.google.com x 610,355 ops/sec ±0.74% (191 runs sampled) + parse en.wikipedia.org x 290,824 ops/sec ±0.83% (192 runs sampled) + parse linkedin.com x 169,887 ops/sec ±0.57% (192 runs sampled) + parse maps.google.com x 286,005 ops/sec ±0.55% (189 runs sampled) + parse microsoft.com x 36,237 ops/sec ±0.59% (192 runs sampled) + parse play.google.com x 373,727 ops/sec ±0.74% (193 runs sampled) + parse plus.google.com x 586,023 ops/sec ±0.56% (189 runs sampled) + parse support.google.com x 329,710 ops/sec ±0.49% (188 runs sampled) + parse www.google.com x 287,861 ops/sec ±0.53% (193 runs sampled) + parse youtu.be x 554,207 ops/sec ±0.71% (193 runs sampled) + parse youtube.com x 558,357 ops/sec ±0.60% (188 runs sampled) + > node benchmark/parse.js - cookie.parse + cookie.parse - generic 6 tests completed. - simple x 1,583,012 ops/sec ±0.70% (191 runs sampled) - decode x 958,910 ops/sec ±0.44% (193 runs sampled) - unquote x 974,390 ops/sec ±4.49% (188 runs sampled) - duplicates x 572,274 ops/sec ±0.55% (190 runs sampled) - 10 cookies x 164,955 ops/sec ±0.69% (186 runs sampled) - 100 cookies x 15,415 ops/sec ±0.57% (193 runs sampled) + simple x 1,546,505 ops/sec ±0.67% (187 runs sampled) + decode x 842,073 ops/sec ±8.38% (171 runs sampled) + unquote x 931,934 ops/sec ±6.60% (193 runs sampled) + duplicates x 575,230 ops/sec ±0.63% (190 runs sampled) + 10 cookies x 164,555 ops/sec ±0.79% (189 runs sampled) + 100 cookies x 15,370 ops/sec ±0.63% (193 runs sampled) ``` ## References diff --git a/benchmark/parse-top.js b/benchmark/parse-top.js new file mode 100644 index 0000000..924f45f --- /dev/null +++ b/benchmark/parse-top.js @@ -0,0 +1,47 @@ +/** + * Module dependencies. + */ + +var benchmark = require('benchmark') +var benchmarks = require('beautify-benchmark') +var top = require('./parse-top.json') + +/** + * Globals for benchmark.js + */ + +global.cookie = require('..') + +var suite = new benchmark.Suite() + +Object.keys(top).forEach(function (domain) { + suite.add({ + name: 'parse ' + domain, + minSamples: 100, + fn: 'var val = cookie.parse(' + JSON.stringify(top[domain]) + ')' + }) +}) + +suite.on('start', function onCycle (event) { + process.stdout.write(' cookie.parse - top sites\n\n') +}) + +suite.on('cycle', function onCycle (event) { + benchmarks.add(event.target) +}) + +suite.on('complete', function onComplete () { + benchmarks.log() +}) + +suite.run({async: false}) + +function gencookies (num) { + var str = '' + + for (var i = 0; i < num; i++) { + str += '; foo' + i + '=bar' + } + + return str.substr(2) +} diff --git a/benchmark/parse-top.json b/benchmark/parse-top.json new file mode 100644 index 0000000..117ac91 --- /dev/null +++ b/benchmark/parse-top.json @@ -0,0 +1,17 @@ +{ + "accounts.google.com": "__Ulll-UUUU=0:UUlUlUlUllUU0UllUll0llU0lUlUUU:0UUUUlllllUUUU0l", + "apple.com": "lll=UU", + "cloudflare.com": "__ll_ll=U0lUlUUlUlll00l00UlUUlUlllUlUUlUlUUlUUlUllU-0000000000-0-UllUUU0lU0U0Ul0lUl0lUUlUllU0UllllUlU00UllUll+ll0Ull0UlU0lU00UUlUllllU0U0UUUUllUUUUU0lUU/lUlUl00ll0UUUlUUUUUU", + "docs.google.com": "__Ulll-UUUU=0:lU0llUl0llUllUUl0l0UU0UUUlllUl:0UUlllUlUl-l0U0l", + "drive.google.com": "__Ulll-UUUU=0:l00_0UlU0lU0UlU0ll0l0l0UUllUUl:0ll0Ul0lUllUl-ll", + "en.wikipedia.org": "UUU-Ulll-Ulllll=00-Ull-0000; UUU-Ulll-Ulllll-Ulllll=00-Ull-0000; UllUU=UU:UU:Ulllllllllll:00.00:-00.00:l0", + "linkedin.com": "UUUUUUUUUU=llll:0000000000000000000; llll=l=0&llll=ll-ll; lllllll=\"l=0&l0l0lll0-0000-0000-0000-l000ll00l000\"; llllllll=\"l=0&000000000000000000lll0-l0l0-000l-00ll-000000l00000UUUl0lU00Ul0lll0UlUlllllUU0UlUlU\"; llll=\"l=UUUU00:l=U:l=U:l=U:l=U:l=0000:l=0:l=0:l=0000000000:l=0000000000:l=0:lll=UUUUUUlll0lUUU00UUll0lUUUlllUlUU\"", + "maps.google.com": "0U_UUU=0000-00-00-00; UUU=000=UlUUl00lU0UUllUUll0UllUUlllllUlllll-lU-l0UUl0UUlllUlU0UUU0UUllUl0UlUU0lllUUU0UllUlll00llll0lll0ll-l-0lUlUlUUllU0UllUUl00llllU0lUU0UU0U0UUUUlllUll0lUUlllUUl0lllUU0lllUllUUU", + "microsoft.com": "llUllllUllllll=0; UUUU=000U00000U000U0U000000000U0U0U00; U-UU-UUUUUUUU=lll=llllll000l0%0lllllllllllll000%0llllllllllll%0lllllllllllllllll%0lllllllllllllllll%0lllllllllllllllllllllll%0lllllllllllllllllll%0llll-lll-lllll0l0ll&lll=0000l00l-0l00-0l00-l00l-ll00ll00l0l0; U-UU-Ulll=0; lllll_UllUU=0000000000~ll=00~ll=000000000lll00ll000lll0ll0l000l0; lllll_UllUU=0000000000~ll=00~ll=000000000lll00ll000lll0ll0l000l0", + "play.google.com": "UUU=000=l0llUUlUl0U-llUlUU0lllU-llllU0U0lllllllU0llllUU_0llUllllUU0lllUUUUl_U0Ull-0UlUllUU-lU0llU0U0lUU0llUUlUllUll00llUU0l0UllUlUUUllllUUllUlUUllUlUlUl0-lUll0lllUlUUUUUllll0l0lll", + "plus.google.com": "__Ulll-UUUU=0:ll0U0UlU0U-0lU00Ul0lU00llUUUUU:llUUllllUUUl0lUl", + "support.google.com": "UUU=000=U00lUUl0_UlllU0UlU0Ul0UlUlU0Ulll0UU0UUlllll00l0UUll0UllUl0lUlUUUU0UlUlUlllU0UUllUlUUll0l0_lllUllUllllUUUU0U0Ul0UlllllUUlllllU0U-0UllUllUlU0l0lllU0ll0UU0UU0lUU0lUlllUlUUUll; UUU=000=U00lUUl0_UlllU0UlU0Ul0UlUlU0Ulll0UU0UUlllll00l0UUll0UllUl0lUlUUUU0UlUlUlllU0UUllUlUUll0l0_lllUllUllllUUUU0U0Ul0UlllllUUlllllU0U-0UllUllUlU0l0lllU0ll0UU0UU0lUU0lUlllUlUUUll", + "www.google.com": "0U_UUU=0000-00-00-00; UUU=000=llUUUUU_-UlUlUl0U0UU0lUUl0UUUUU0lUll-0Ullll0ll0UUU_Ul00UlUll0lllUlllUlllUUl0lUUl0Ul0U00UUl00lUlUUllUlUlUll0l_lUUU0UlUl0UUlUlllllUU00Ul0llUlUlUl_UU_UUllUUlllUlUUlllUllUlUUl", + "youtu.be": "UUU=0; UUU=0lUllllUUUU; UUUUUUU_UUUU0_UUUU=UUllllUllUl", + "youtube.com": "UUU=0; UUU=lUlU0lllUll; UUUUUUU_UUUU0_UUUU=0UllU0UlU00" +} diff --git a/benchmark/parse.js b/benchmark/parse.js index 3ec985a..5310230 100644 --- a/benchmark/parse.js +++ b/benchmark/parse.js @@ -50,7 +50,7 @@ suite.add({ }) suite.on('start', function onCycle (event) { - process.stdout.write(' cookie.parse\n\n') + process.stdout.write(' cookie.parse - generic\n\n') }) suite.on('cycle', function onCycle (event) { diff --git a/package.json b/package.json index 5d96205..7adccdd 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,8 @@ "eslint": "7.32.0", "eslint-plugin-markdown": "2.2.1", "mocha": "9.1.4", - "nyc": "15.1.0" + "nyc": "15.1.0", + "top-sites": "1.1.85" }, "files": [ "HISTORY.md", @@ -35,6 +36,7 @@ "test": "mocha --reporter spec --bail --check-leaks --ui qunit test/", "test-ci": "nyc --reporter=lcov --reporter=text npm test", "test-cov": "nyc --reporter=html --reporter=text npm test", + "update-bench": "node scripts/update-benchmark.js", "version": "node scripts/version-history.js && git add HISTORY.md" } } diff --git a/scripts/update-benchmark.js b/scripts/update-benchmark.js new file mode 100644 index 0000000..ea786fc --- /dev/null +++ b/scripts/update-benchmark.js @@ -0,0 +1,66 @@ +'use strict' + +var fs = require('fs') +var http = require('http') +var https = require('https') +var path = require('path') +var topSites = require('top-sites') +var url = require('url') + +var BENCH_COOKIES_FILE = path.join(__dirname, '..', 'benchmark', 'parse-top.json') + +getAllCookies(topSites.slice(0, 20), function (err, cookies) { + if (err) throw err + var str = '{\n' + + Object.keys(cookies).sort().map(function (key) { + return ' ' + JSON.stringify(key) + ': ' + JSON.stringify(cookies[key]) + }).join(',\n') + + '\n}\n' + fs.writeFileSync(BENCH_COOKIES_FILE, str) +}) + +function get (href, callback) { + var protocol = url.parse(href, false, true).protocol + var proto = protocol === 'https:' ? https : http + + proto.get(href) + .on('error', callback) + .on('response', function (res) { + if (res.headers.location && res.statusCode >= 300 && res.statusCode < 400) { + get(url.resolve(href, res.headers.location), callback) + } else { + callback(null, res) + } + }) +} + +function getAllCookies (sites, callback) { + var all = Object.create(null) + var wait = sites.length + + sites.forEach(function (site) { + getCookies(site, function (err, cookies) { + if (!err && cookies.length) { + all[site.rootDomain] = cookies.map(obfuscate).join('; ') + } + if (!--wait) { + callback(null, all) + } + }) + }) +} + +function getCookies (site, callback) { + var href = url.format({ hostname: site.rootDomain, protocol: 'http' }) + get(href, function (err, res) { + if (err) return callback(err) + var cookies = (res.headers['set-cookie'] || []).map(function (c) { return c.split(';')[0] }) + callback(null, cookies) + }) +} + +function obfuscate (str) { + return str.replace(/[a-z]/g, function () { return 'l' }) + .replace(/[A-Z]/g, function () { return 'U' }) + .replace(/[0-9]/g, function () { return '0' }) +} From aa1a335d2b85e919c028c59d1d13db3fc371502b Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Tue, 18 Jan 2022 23:24:44 -0500 Subject: [PATCH 083/159] pref: remove unnecessary regexp in parse --- HISTORY.md | 5 +++++ README.md | 42 +++++++++++++++++++++--------------------- index.js | 3 +-- 3 files changed, 27 insertions(+), 23 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index ce080e0..eb302e7 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,3 +1,8 @@ +unreleased +========== + + * pref: remove unnecessary regexp in parse + 0.4.1 / 2020-04-21 ================== diff --git a/README.md b/README.md index 602fd17..6f91e78 100644 --- a/README.md +++ b/README.md @@ -225,21 +225,21 @@ $ npm run bench 15 tests completed. - parse accounts.google.com x 522,610 ops/sec ±7.53% (191 runs sampled) - parse apple.com x 1,617,049 ops/sec ±12.52% (173 runs sampled) - parse cloudflare.com x 379,557 ops/sec ±3.46% (189 runs sampled) - parse docs.google.com x 603,625 ops/sec ±1.33% (189 runs sampled) - parse drive.google.com x 610,355 ops/sec ±0.74% (191 runs sampled) - parse en.wikipedia.org x 290,824 ops/sec ±0.83% (192 runs sampled) - parse linkedin.com x 169,887 ops/sec ±0.57% (192 runs sampled) - parse maps.google.com x 286,005 ops/sec ±0.55% (189 runs sampled) - parse microsoft.com x 36,237 ops/sec ±0.59% (192 runs sampled) - parse play.google.com x 373,727 ops/sec ±0.74% (193 runs sampled) - parse plus.google.com x 586,023 ops/sec ±0.56% (189 runs sampled) - parse support.google.com x 329,710 ops/sec ±0.49% (188 runs sampled) - parse www.google.com x 287,861 ops/sec ±0.53% (193 runs sampled) - parse youtu.be x 554,207 ops/sec ±0.71% (193 runs sampled) - parse youtube.com x 558,357 ops/sec ±0.60% (188 runs sampled) + parse accounts.google.com x 532,499 ops/sec ±4.78% (180 runs sampled) + parse apple.com x 1,390,922 ops/sec ±0.74% (190 runs sampled) + parse cloudflare.com x 387,601 ops/sec ±0.43% (192 runs sampled) + parse docs.google.com x 543,040 ops/sec ±3.70% (190 runs sampled) + parse drive.google.com x 562,937 ops/sec ±0.67% (190 runs sampled) + parse en.wikipedia.org x 286,042 ops/sec ±0.62% (190 runs sampled) + parse linkedin.com x 176,883 ops/sec ±0.73% (189 runs sampled) + parse maps.google.com x 290,107 ops/sec ±0.56% (191 runs sampled) + parse microsoft.com x 36,340 ops/sec ±0.70% (192 runs sampled) + parse play.google.com x 371,488 ops/sec ±0.57% (192 runs sampled) + parse plus.google.com x 538,450 ops/sec ±0.59% (190 runs sampled) + parse support.google.com x 348,596 ops/sec ±0.40% (193 runs sampled) + parse www.google.com x 295,398 ops/sec ±0.37% (192 runs sampled) + parse youtu.be x 560,645 ops/sec ±0.42% (191 runs sampled) + parse youtube.com x 559,285 ops/sec ±0.53% (192 runs sampled) > node benchmark/parse.js @@ -247,12 +247,12 @@ $ npm run bench 6 tests completed. - simple x 1,546,505 ops/sec ±0.67% (187 runs sampled) - decode x 842,073 ops/sec ±8.38% (171 runs sampled) - unquote x 931,934 ops/sec ±6.60% (193 runs sampled) - duplicates x 575,230 ops/sec ±0.63% (190 runs sampled) - 10 cookies x 164,555 ops/sec ±0.79% (189 runs sampled) - 100 cookies x 15,370 ops/sec ±0.63% (193 runs sampled) + simple x 1,268,784 ops/sec ±0.60% (192 runs sampled) + decode x 802,402 ops/sec ±3.88% (186 runs sampled) + unquote x 765,847 ops/sec ±7.91% (185 runs sampled) + duplicates x 557,076 ops/sec ±0.60% (190 runs sampled) + 10 cookies x 171,248 ops/sec ±0.61% (189 runs sampled) + 100 cookies x 16,283 ops/sec ±0.43% (193 runs sampled) ``` ## References diff --git a/index.js b/index.js index 760f32e..ccba682 100644 --- a/index.js +++ b/index.js @@ -22,7 +22,6 @@ exports.serialize = serialize; var decode = decodeURIComponent; var encode = encodeURIComponent; -var pairSplitRegExp = /; */; /** * RegExp to match field-content in RFC 7230 sec 3.2 @@ -53,7 +52,7 @@ function parse(str, options) { var obj = {} var opt = options || {}; - var pairs = str.split(pairSplitRegExp); + var pairs = str.split(';') var dec = opt.decode || decode; for (var i = 0; i < pairs.length; i++) { From 2dc6662dc28bdfafd868d6772c5e7272fc3ada47 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sat, 22 Jan 2022 23:42:37 -0500 Subject: [PATCH 084/159] bench: preserve decode behavior for top cookies --- README.md | 42 ++++++++++++++++++------------------- benchmark/parse-top.json | 26 +++++++++++------------ scripts/update-benchmark.js | 5 ++++- 3 files changed, 38 insertions(+), 35 deletions(-) diff --git a/README.md b/README.md index 6f91e78..e275c70 100644 --- a/README.md +++ b/README.md @@ -225,21 +225,21 @@ $ npm run bench 15 tests completed. - parse accounts.google.com x 532,499 ops/sec ±4.78% (180 runs sampled) - parse apple.com x 1,390,922 ops/sec ±0.74% (190 runs sampled) - parse cloudflare.com x 387,601 ops/sec ±0.43% (192 runs sampled) - parse docs.google.com x 543,040 ops/sec ±3.70% (190 runs sampled) - parse drive.google.com x 562,937 ops/sec ±0.67% (190 runs sampled) - parse en.wikipedia.org x 286,042 ops/sec ±0.62% (190 runs sampled) - parse linkedin.com x 176,883 ops/sec ±0.73% (189 runs sampled) - parse maps.google.com x 290,107 ops/sec ±0.56% (191 runs sampled) - parse microsoft.com x 36,340 ops/sec ±0.70% (192 runs sampled) - parse play.google.com x 371,488 ops/sec ±0.57% (192 runs sampled) - parse plus.google.com x 538,450 ops/sec ±0.59% (190 runs sampled) - parse support.google.com x 348,596 ops/sec ±0.40% (193 runs sampled) - parse www.google.com x 295,398 ops/sec ±0.37% (192 runs sampled) - parse youtu.be x 560,645 ops/sec ±0.42% (191 runs sampled) - parse youtube.com x 559,285 ops/sec ±0.53% (192 runs sampled) + parse accounts.google.com x 504,358 ops/sec ±6.55% (171 runs sampled) + parse apple.com x 1,369,991 ops/sec ±0.84% (189 runs sampled) + parse cloudflare.com x 360,669 ops/sec ±3.75% (182 runs sampled) + parse docs.google.com x 521,496 ops/sec ±4.90% (180 runs sampled) + parse drive.google.com x 553,514 ops/sec ±0.59% (189 runs sampled) + parse en.wikipedia.org x 286,052 ops/sec ±0.62% (188 runs sampled) + parse linkedin.com x 178,817 ops/sec ±0.61% (192 runs sampled) + parse maps.google.com x 284,585 ops/sec ±0.68% (188 runs sampled) + parse microsoft.com x 161,230 ops/sec ±0.56% (192 runs sampled) + parse play.google.com x 352,144 ops/sec ±1.01% (181 runs sampled) + parse plus.google.com x 275,204 ops/sec ±7.78% (156 runs sampled) + parse support.google.com x 339,493 ops/sec ±1.02% (191 runs sampled) + parse www.google.com x 286,110 ops/sec ±0.90% (191 runs sampled) + parse youtu.be x 548,557 ops/sec ±0.60% (184 runs sampled) + parse youtube.com x 545,293 ops/sec ±0.65% (191 runs sampled) > node benchmark/parse.js @@ -247,12 +247,12 @@ $ npm run bench 6 tests completed. - simple x 1,268,784 ops/sec ±0.60% (192 runs sampled) - decode x 802,402 ops/sec ±3.88% (186 runs sampled) - unquote x 765,847 ops/sec ±7.91% (185 runs sampled) - duplicates x 557,076 ops/sec ±0.60% (190 runs sampled) - 10 cookies x 171,248 ops/sec ±0.61% (189 runs sampled) - 100 cookies x 16,283 ops/sec ±0.43% (193 runs sampled) + simple x 1,266,646 ops/sec ±0.65% (191 runs sampled) + decode x 838,413 ops/sec ±0.60% (191 runs sampled) + unquote x 877,820 ops/sec ±0.72% (189 runs sampled) + duplicates x 516,680 ops/sec ±0.61% (191 runs sampled) + 10 cookies x 156,874 ops/sec ±0.52% (189 runs sampled) + 100 cookies x 14,663 ops/sec ±0.53% (191 runs sampled) ``` ## References diff --git a/benchmark/parse-top.json b/benchmark/parse-top.json index 117ac91..5b4d7d7 100644 --- a/benchmark/parse-top.json +++ b/benchmark/parse-top.json @@ -1,17 +1,17 @@ { - "accounts.google.com": "__Ulll-UUUU=0:UUlUlUlUllUU0UllUll0llU0lUlUUU:0UUUUlllllUUUU0l", + "accounts.google.com": "__Ulll-UUUU=0:-0UlUlll0UUU0UUlUll00UlU0lUUUl:lUlUllUlUlU0ll0l", "apple.com": "lll=UU", - "cloudflare.com": "__ll_ll=U0lUlUUlUlll00l00UlUUlUlllUlUUlUlUUlUUlUllU-0000000000-0-UllUUU0lU0U0Ul0lUl0lUUlUllU0UllllUlU00UllUll+ll0Ull0UlU0lU00UUlUllllU0U0UUUUllUUUUU0lUU/lUlUl00ll0UUUlUUUUUU", - "docs.google.com": "__Ulll-UUUU=0:lU0llUl0llUllUUl0l0UU0UUUlllUl:0UUlllUlUl-l0U0l", - "drive.google.com": "__Ulll-UUUU=0:l00_0UlU0lU0UlU0ll0l0l0UUllUUl:0ll0Ul0lUllUl-ll", + "cloudflare.com": "__ll_ll=lUlll_0U_lU0llUllU00l00Ul0UUl00UlU0l0UlUU00-0000000000-0-UllllUlUUlUll0ll0llUl0lll0UUU00l0U0lUU+UUUlllU/lUlllU00l00lU0/+UllUlUUlU0lll0UlUlUlUlUUUllll0UllllUll0UlUlll", + "docs.google.com": "__Ulll-UUUU=0:lUUUUUlllU0UUUUlll0Ullllll0lUU:llUU0lUUllUU0Ull", + "drive.google.com": "__Ulll-UUUU=0:lUlU0U0U0ll0lUl0l0UlUUl_0Ullll:U0Ull00U0lUl00ll", "en.wikipedia.org": "UUU-Ulll-Ulllll=00-Ull-0000; UUU-Ulll-Ulllll-Ulllll=00-Ull-0000; UllUU=UU:UU:Ulllllllllll:00.00:-00.00:l0", - "linkedin.com": "UUUUUUUUUU=llll:0000000000000000000; llll=l=0&llll=ll-ll; lllllll=\"l=0&l0l0lll0-0000-0000-0000-l000ll00l000\"; llllllll=\"l=0&000000000000000000lll0-l0l0-000l-00ll-000000l00000UUUl0lU00Ul0lll0UlUlllllUU0UlUlU\"; llll=\"l=UUUU00:l=U:l=U:l=U:l=U:l=0000:l=0:l=0:l=0000000000:l=0000000000:l=0:lll=UUUUUUlll0lUUU00UUll0lUUUlllUlUU\"", - "maps.google.com": "0U_UUU=0000-00-00-00; UUU=000=UlUUl00lU0UUllUUll0UllUUlllllUlllll-lU-l0UUl0UUlllUlU0UUU0UUllUl0UlUU0lllUUU0UllUlll00llll0lll0ll-l-0lUlUlUUllU0UllUUl00llllU0lUU0UU0U0UUUUlllUll0lUUlllUUl0lllUU0lllUllUUU", - "microsoft.com": "llUllllUllllll=0; UUUU=000U00000U000U0U000000000U0U0U00; U-UU-UUUUUUUU=lll=llllll000l0%0lllllllllllll000%0llllllllllll%0lllllllllllllllll%0lllllllllllllllll%0lllllllllllllllllllllll%0lllllllllllllllllll%0llll-lll-lllll0l0ll&lll=0000l00l-0l00-0l00-l00l-ll00ll00l0l0; U-UU-Ulll=0; lllll_UllUU=0000000000~ll=00~ll=000000000lll00ll000lll0ll0l000l0; lllll_UllUU=0000000000~ll=00~ll=000000000lll00ll000lll0ll0l000l0", - "play.google.com": "UUU=000=l0llUUlUl0U-llUlUU0lllU-llllU0U0lllllllU0llllUU_0llUllllUU0lllUUUUl_U0Ull-0UlUllUU-lU0llU0U0lUU0llUUlUllUll00llUU0l0UllUlUUUllllUUllUlUUllUlUlUl0-lUll0lllUlUUUUUllll0l0lll", - "plus.google.com": "__Ulll-UUUU=0:ll0U0UlU0U-0lU00Ul0lU00llUUUUU:llUUllllUUUl0lUl", - "support.google.com": "UUU=000=U00lUUl0_UlllU0UlU0Ul0UlUlU0Ulll0UU0UUlllll00l0UUll0UllUl0lUlUUUU0UlUlUlllU0UUllUlUUll0l0_lllUllUllllUUUU0U0Ul0UlllllUUlllllU0U-0UllUllUlU0l0lllU0ll0UU0UU0lUU0lUlllUlUUUll; UUU=000=U00lUUl0_UlllU0UlU0Ul0UlUlU0Ulll0UU0UUlllll00l0UUll0UllUl0lUlUUUU0UlUlUlllU0UUllUlUUll0l0_lllUllUllllUUUU0U0Ul0UlllllUUlllllU0U-0UllUllUlU0l0lllU0ll0UU0UU0lUU0lUlllUlUUUll", - "www.google.com": "0U_UUU=0000-00-00-00; UUU=000=llUUUUU_-UlUlUl0U0UU0lUUl0UUUUU0lUll-0Ullll0ll0UUU_Ul00UlUll0lllUlllUlllUUl0lUUl0Ul0U00UUl00lUlUUllUlUlUll0l_lUUU0UlUl0UUlUlllllUU00Ul0llUlUlUl_UU_UUllUUlllUlUUlllUllUlUUl", - "youtu.be": "UUU=0; UUU=0lUllllUUUU; UUUUUUU_UUUU0_UUUU=UUllllUllUl", - "youtube.com": "UUU=0; UUU=lUlU0lllUll; UUUUUUU_UUUU0_UUUU=0UllU0UlU00" + "linkedin.com": "UUUUUUUUUU=llll:0000000000000000000; llll=l=0&llll=ll-ll; lllllll=\"l=0&0l00l0l0-0000-0000-00ll-ll0000000l00\"; llllllll=\"l=0&00000000000000l0lll000-0l0l-0l00-0000-ll00l0000l00UUUUUUUlUU0llUllll00lll0ll0-lll0\"; llll=\"l=UUUU00:l=U:l=U:l=U:l=U:l=0000:l=0:l=0:l=0000000000:l=0000000000:l=0:lll=UUUUllUU-lllU0UU000lUU0Ulllll0ll\"", + "maps.google.com": "0U_UUU=0000-00-00-00; UUU=000=lUlUUUlllUUUllUUUllll0UUll0lUlU0lllUUUlUllUUllllUUlUUU--lUllUlUlUUl_lUll0UU0Ull-UU0UlUllUlUll0UUllUU0lUUlllUll0lUUlUUlllU00UU0UlUllU0l0U000UUllllU0UU00_llUlllUUlUUllUUU0lU", + "microsoft.com": "llUllllUllllll=0; UUUU=0UU00UUU00U0000000U00U0000000000; U-UU-UUUUUUUU=lll=llllll000l0%22llllllllllll000%22lllllllllll%22llllllllllllllll%22llllllllllllllll%22llllllllllllllllllllll%22llllllllllllllllll%22lll-lll-lllll0l0ll&lll=0000l000-0l00-00l0-0l00-l00l00l00ll0; U-UU-Ulll=0; lllll_UllUU=0000000000~ll=00~ll=l0l000l0ll00000ll000l000000000ll; lllll_UllUU=0000000000~ll=00~ll=l0l000l0ll00000ll000l000000000ll", + "play.google.com": "UUU=000=UlU0lUlUlU0llllUUU0lUlUUUl0llUllUl00U0UU0lUllUUlll0ll0U0lUlllUUUUl0ll0UUUUU0UllU-Ul-lUUUUlUlUU00UUlUUlllUlUU0UUUllUUl0UUUUllU0U0lUl0llUUl0ll-UllUUlUU0U0UUU000lUUUlUl0llU0U", + "plus.google.com": "__Ulll-UUUU=0:0UlllUllU0llUlUlU0UllU0UU0lUlU:0ll0Ulllll0lU0l0", + "support.google.com": "UUU=000=UU0UlUl0Ull0UUll_lU0llUlllUlll0_Ul0lUlUllUUUU0UlU0ll0UlllU0lU0lllllUlUUUUUlUUlUlUlUUUllUU0UU0UUU00l0l_0UU_0UUUUUUl_UllllllllUlll0U0UlUUlU0UU_-U-UlU_lUll0U0lU_UUU0llUlUlUUl; UUU=000=UU0UlUl0Ull0UUll_lU0llUlllUlll0_Ul0lUlUllUUUU0UlU0ll0UlllU0lU0lllllUlUUUUUlUUlUlUlUUUllUU0UU0UUU00l0l_0UU_0UUUUUUl_UllllllllUlll0U0UlUUlU0UU_-U-UlU_lUll0U0lU_UUU0llUlUlUUl", + "www.google.com": "0U_UUU=0000-00-00-00; UUU=000=UU0llUUlUUUllUlllUUl00UUll-lU0U00llUUl0UUUlUlUU0UU-0l0UUUlUUlUUUU0UUUllllUUlU0l0UUUlUUUl0UlUl0UUlUUl0U0lUUUllUlU0lUU0UUllUUlllU-UU0lUU0UllUlllUllUll0-l_UllUUUllUl00UUU0lll", + "youtu.be": "UUU=0; UUU=lUUlUlUU0ll; UUUUUUU_UUUU0_UUUU=0UlllUllUUl", + "youtube.com": "UUU=0; UUU=0ll00lU0UUU; UUUUUUU_UUUU0_UUUU=UlUUUUlUU0U" } diff --git a/scripts/update-benchmark.js b/scripts/update-benchmark.js index ea786fc..23cdcfe 100644 --- a/scripts/update-benchmark.js +++ b/scripts/update-benchmark.js @@ -60,7 +60,10 @@ function getCookies (site, callback) { } function obfuscate (str) { - return str.replace(/[a-z]/g, function () { return 'l' }) + return str + .replace(/%[0-9a-f]{2}/gi, function () { return '%__' }) + .replace(/[a-z]/g, function () { return 'l' }) .replace(/[A-Z]/g, function () { return 'U' }) .replace(/[0-9]/g, function () { return '0' }) + .replace(/%__/g, function () { return '%22' }) } From 04be428b438605b48ad6af503227b817c07b9b52 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sun, 23 Jan 2022 13:32:38 -0500 Subject: [PATCH 085/159] lint: remove deprecated String.prototype.substr --- index.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index ccba682..7e6b777 100644 --- a/index.js +++ b/index.js @@ -57,15 +57,15 @@ function parse(str, options) { for (var i = 0; i < pairs.length; i++) { var pair = pairs[i]; - var eq_idx = pair.indexOf('='); + var index = pair.indexOf('=') // skip things that don't look like key=value - if (eq_idx < 0) { + if (index < 0) { continue; } - var key = pair.substr(0, eq_idx).trim() - var val = pair.substr(++eq_idx, pair.length).trim(); + var key = pair.substring(0, index).trim() + var val = pair.substring(index + 1, pair.length).trim() // quoted values if ('"' == val[0]) { From 009b3cb1f818c6dccd7ef70a805602ba06297a0e Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sun, 30 Jan 2022 21:32:43 -0500 Subject: [PATCH 086/159] pref: read value only when assigning in parse --- HISTORY.md | 1 + index.js | 13 +++++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index eb302e7..3483980 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,6 +1,7 @@ unreleased ========== + * pref: read value only when assigning in parse * pref: remove unnecessary regexp in parse 0.4.1 / 2020-04-21 diff --git a/index.js b/index.js index 7e6b777..55331d9 100644 --- a/index.js +++ b/index.js @@ -65,15 +65,16 @@ function parse(str, options) { } var key = pair.substring(0, index).trim() - var val = pair.substring(index + 1, pair.length).trim() - - // quoted values - if ('"' == val[0]) { - val = val.slice(1, -1); - } // only assign once if (undefined == obj[key]) { + var val = pair.substring(index + 1, pair.length).trim() + + // quoted values + if (val[0] === '"') { + val = val.slice(1, -1) + } + obj[key] = tryDecode(val, dec); } } From fadc4bc981c6cc44b74e1d82a9c6cd6a31fc00c7 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sun, 30 Jan 2022 21:36:32 -0500 Subject: [PATCH 087/159] build: Node.js@14.19 --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b29acae..afbc17b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -113,7 +113,7 @@ jobs: node-version: "13.14" - name: Node.js 14.x - node-version: "14.18" + node-version: "14.19" - name: Node.js 15.x node-version: "15.14" From 519feb52ed369856385ddc6019ea5540e08dcd2d Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sun, 30 Jan 2022 21:39:37 -0500 Subject: [PATCH 088/159] build: mocha@9.2.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 7adccdd..7eef044 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "benchmark": "2.1.4", "eslint": "7.32.0", "eslint-plugin-markdown": "2.2.1", - "mocha": "9.1.4", + "mocha": "9.2.0", "nyc": "15.1.0", "top-sites": "1.1.85" }, From 55bac40d944e65554ecce9e5d567d17fb62d9ccc Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 2 Feb 2022 18:28:08 -0500 Subject: [PATCH 089/159] 0.4.2 --- HISTORY.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index 3483980..2d21760 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,5 +1,5 @@ -unreleased -========== +0.4.2 / 2022-02-02 +================== * pref: read value only when assigning in parse * pref: remove unnecessary regexp in parse diff --git a/package.json b/package.json index 7eef044..cd40d0d 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "cookie", "description": "HTTP server cookie parsing and serialization", - "version": "0.4.1", + "version": "0.4.2", "author": "Roman Shtylman ", "contributors": [ "Douglas Christopher Wilson " From ecb01f36212654bfcedd3e4f341908e62339af8d Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Tue, 8 Feb 2022 22:43:00 -0500 Subject: [PATCH 090/159] build: Node.js@16.14 --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index afbc17b..7de5651 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -119,7 +119,7 @@ jobs: node-version: "15.14" - name: Node.js 16.x - node-version: "16.13" + node-version: "16.14" - name: Node.js 17.x node-version: "17.4" From 49dab8bd2780c998660c6b43bb782e7a6a62c187 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Tue, 8 Feb 2022 22:49:00 -0500 Subject: [PATCH 091/159] build: top-sites@1.1.87 --- README.md | 60 ++++++++++++++++++++-------------------- benchmark/parse-top.json | 26 ++++++++--------- package.json | 2 +- 3 files changed, 44 insertions(+), 44 deletions(-) diff --git a/README.md b/README.md index e275c70..f8389ff 100644 --- a/README.md +++ b/README.md @@ -198,12 +198,12 @@ $ npm test ``` $ npm run bench -> cookie@0.4.1 bench +> cookie@0.4.2 bench > node benchmark/index.js - node@16.13.1 - v8@9.4.146.24-node.14 - uv@1.42.0 + node@16.14.0 + v8@9.4.146.24-node.20 + uv@1.43.0 zlib@1.2.11 brotli@1.0.9 ares@1.18.1 @@ -211,11 +211,11 @@ $ npm run bench nghttp2@1.45.1 napi@8 llhttp@6.0.4 - openssl@1.1.1l+quic - cldr@39.0 - icu@69.1 - tz@2021a - unicode@13.0 + openssl@1.1.1m+quic + cldr@40.0 + icu@70.1 + tz@2021a3 + unicode@14.0 ngtcp2@0.1.0-DEV nghttp3@0.1.0-DEV @@ -225,21 +225,21 @@ $ npm run bench 15 tests completed. - parse accounts.google.com x 504,358 ops/sec ±6.55% (171 runs sampled) - parse apple.com x 1,369,991 ops/sec ±0.84% (189 runs sampled) - parse cloudflare.com x 360,669 ops/sec ±3.75% (182 runs sampled) - parse docs.google.com x 521,496 ops/sec ±4.90% (180 runs sampled) - parse drive.google.com x 553,514 ops/sec ±0.59% (189 runs sampled) - parse en.wikipedia.org x 286,052 ops/sec ±0.62% (188 runs sampled) - parse linkedin.com x 178,817 ops/sec ±0.61% (192 runs sampled) - parse maps.google.com x 284,585 ops/sec ±0.68% (188 runs sampled) - parse microsoft.com x 161,230 ops/sec ±0.56% (192 runs sampled) - parse play.google.com x 352,144 ops/sec ±1.01% (181 runs sampled) - parse plus.google.com x 275,204 ops/sec ±7.78% (156 runs sampled) - parse support.google.com x 339,493 ops/sec ±1.02% (191 runs sampled) - parse www.google.com x 286,110 ops/sec ±0.90% (191 runs sampled) - parse youtu.be x 548,557 ops/sec ±0.60% (184 runs sampled) - parse youtube.com x 545,293 ops/sec ±0.65% (191 runs sampled) + parse apple.com x 634,820 ops/sec ±0.59% (187 runs sampled) + parse cloudflare.com x 215,701 ops/sec ±1.73% (178 runs sampled) + parse docs.google.com x 271,466 ops/sec ±2.50% (184 runs sampled) + parse drive.google.com x 301,338 ops/sec ±0.69% (186 runs sampled) + parse en.wikipedia.org x 160,666 ops/sec ±1.00% (186 runs sampled) + parse linkedin.com x 95,545 ops/sec ±2.83% (177 runs sampled) + parse maps.google.com x 163,629 ops/sec ±1.26% (185 runs sampled) + parse microsoft.com x 86,596 ops/sec ±0.72% (187 runs sampled) + parse play.google.com x 221,059 ops/sec ±0.79% (187 runs sampled) + parse plus.google.com x 302,712 ops/sec ±0.61% (185 runs sampled) + parse sites.google.com x 309,551 ops/sec ±0.43% (190 runs sampled) + parse support.google.com x 216,781 ops/sec ±0.44% (187 runs sampled) + parse www.google.com x 165,432 ops/sec ±1.03% (188 runs sampled) + parse youtu.be x 293,169 ops/sec ±1.79% (178 runs sampled) + parse youtube.com x 278,482 ops/sec ±0.60% (179 runs sampled) > node benchmark/parse.js @@ -247,12 +247,12 @@ $ npm run bench 6 tests completed. - simple x 1,266,646 ops/sec ±0.65% (191 runs sampled) - decode x 838,413 ops/sec ±0.60% (191 runs sampled) - unquote x 877,820 ops/sec ±0.72% (189 runs sampled) - duplicates x 516,680 ops/sec ±0.61% (191 runs sampled) - 10 cookies x 156,874 ops/sec ±0.52% (189 runs sampled) - 100 cookies x 14,663 ops/sec ±0.53% (191 runs sampled) + simple x 546,939 ops/sec ±1.69% (183 runs sampled) + decode x 411,702 ops/sec ±0.46% (188 runs sampled) + unquote x 412,031 ops/sec ±1.86% (183 runs sampled) + duplicates x 288,746 ops/sec ±0.44% (183 runs sampled) + 10 cookies x 105,597 ops/sec ±0.41% (190 runs sampled) + 100 cookies x 10,534 ops/sec ±0.41% (190 runs sampled) ``` ## References diff --git a/benchmark/parse-top.json b/benchmark/parse-top.json index 5b4d7d7..1ae4c1d 100644 --- a/benchmark/parse-top.json +++ b/benchmark/parse-top.json @@ -1,17 +1,17 @@ { - "accounts.google.com": "__Ulll-UUUU=0:-0UlUlll0UUU0UUlUll00UlU0lUUUl:lUlUllUlUlU0ll0l", "apple.com": "lll=UU", - "cloudflare.com": "__ll_ll=lUlll_0U_lU0llUllU00l00Ul0UUl00UlU0l0UlUU00-0000000000-0-UllllUlUUlUll0ll0llUl0lll0UUU00l0U0lUU+UUUlllU/lUlllU00l00lU0/+UllUlUUlU0lll0UlUlUlUlUUUllll0UllllUll0UlUlll", - "docs.google.com": "__Ulll-UUUU=0:lUUUUUlllU0UUUUlll0Ullllll0lUU:llUU0lUUllUU0Ull", - "drive.google.com": "__Ulll-UUUU=0:lUlU0U0U0ll0lUl0l0UlUUl_0Ullll:U0Ull00U0lUl00ll", + "cloudflare.com": "__ll_ll=lll00UlUlUlll_lUUlUUUl0UllUUUUl0l0UUl0U0UUU-0000000000-0-UU0lllUUUUllU0UUUU0UUl0UU0Ul0Ull0UUll0UlUllUUl0UUU/lUUUUlUUUUUllUlUUlUUUlUllU00l0UllUlll/UUllUlUUllUUl0UUlll", + "docs.google.com": "__Ulll-UUUU=0:UlUU-lU0UUlUU0llUUUl0lllllU0lU:UlUUl0U0UlUUUU0l", + "drive.google.com": "__Ulll-UUUU=0:llllUlUllllU00l0lU0UUllUlllUll:_0lUU0l0lUl-0lUU", "en.wikipedia.org": "UUU-Ulll-Ulllll=00-Ull-0000; UUU-Ulll-Ulllll-Ulllll=00-Ull-0000; UllUU=UU:UU:Ulllllllllll:00.00:-00.00:l0", - "linkedin.com": "UUUUUUUUUU=llll:0000000000000000000; llll=l=0&llll=ll-ll; lllllll=\"l=0&0l00l0l0-0000-0000-00ll-ll0000000l00\"; llllllll=\"l=0&00000000000000l0lll000-0l0l-0l00-0000-ll00l0000l00UUUUUUUlUU0llUllll00lll0ll0-lll0\"; llll=\"l=UUUU00:l=U:l=U:l=U:l=U:l=0000:l=0:l=0:l=0000000000:l=0000000000:l=0:lll=UUUUllUU-lllU0UU000lUU0Ulllll0ll\"", - "maps.google.com": "0U_UUU=0000-00-00-00; UUU=000=lUlUUUlllUUUllUUUllll0UUll0lUlU0lllUUUlUllUUllllUUlUUU--lUllUlUlUUl_lUll0UU0Ull-UU0UlUllUlUll0UUllUU0lUUlllUll0lUUlUUlllU00UU0UlUllU0l0U000UUllllU0UU00_llUlllUUlUUllUUU0lU", - "microsoft.com": "llUllllUllllll=0; UUUU=0UU00UUU00U0000000U00U0000000000; U-UU-UUUUUUUU=lll=llllll000l0%22llllllllllll000%22lllllllllll%22llllllllllllllll%22llllllllllllllll%22llllllllllllllllllllll%22llllllllllllllllll%22lll-lll-lllll0l0ll&lll=0000l000-0l00-00l0-0l00-l00l00l00ll0; U-UU-Ulll=0; lllll_UllUU=0000000000~ll=00~ll=l0l000l0ll00000ll000l000000000ll; lllll_UllUU=0000000000~ll=00~ll=l0l000l0ll00000ll000l000000000ll", - "play.google.com": "UUU=000=UlU0lUlUlU0llllUUU0lUlUUUl0llUllUl00U0UU0lUllUUlll0ll0U0lUlllUUUUl0ll0UUUUU0UllU-Ul-lUUUUlUlUU00UUlUUlllUlUU0UUUllUUl0UUUUllU0U0lUl0llUUl0ll-UllUUlUU0U0UUU000lUUUlUl0llU0U", - "plus.google.com": "__Ulll-UUUU=0:0UlllUllU0llUlUlU0UllU0UU0lUlU:0ll0Ulllll0lU0l0", - "support.google.com": "UUU=000=UU0UlUl0Ull0UUll_lU0llUlllUlll0_Ul0lUlUllUUUU0UlU0ll0UlllU0lU0lllllUlUUUUUlUUlUlUlUUUllUU0UU0UUU00l0l_0UU_0UUUUUUl_UllllllllUlll0U0UlUUlU0UU_-U-UlU_lUll0U0lU_UUU0llUlUlUUl; UUU=000=UU0UlUl0Ull0UUll_lU0llUlllUlll0_Ul0lUlUllUUUU0UlU0ll0UlllU0lU0lllllUlUUUUUlUUlUlUlUUUllUU0UU0UUU00l0l_0UU_0UUUUUUl_UllllllllUlll0U0UlUUlU0UU_-U-UlU_lUll0U0lU_UUU0llUlUlUUl", - "www.google.com": "0U_UUU=0000-00-00-00; UUU=000=UU0llUUlUUUllUlllUUl00UUll-lU0U00llUUl0UUUlUlUU0UU-0l0UUUlUUlUUUU0UUUllllUUlU0l0UUUlUUUl0UlUl0UUlUUl0U0lUUUllUlU0lUU0UUllUUlllU-UU0lUU0UllUlllUllUll0-l_UllUUUllUl00UUU0lll", - "youtu.be": "UUU=0; UUU=lUUlUlUU0ll; UUUUUUU_UUUU0_UUUU=0UlllUllUUl", - "youtube.com": "UUU=0; UUU=0ll00lU0UUU; UUUUUUU_UUUU0_UUUU=UlUUUUlUU0U" + "linkedin.com": "UUUUUUUUUU=llll:0000000000000000000; llll=l=0&llll=ll-ll; lllllll=\"l=0&0lll00l0-0000-0000-0000-lll0ll0l00l0\"; llllllll=\"l=0&00000000000000l000l000-l0ll-00l0-0ll0-0000l0ll0l00UUUUlU-Ul-lllllUUUUUllUUUlUlUUll\"; llll=\"l=UUUU00:l=U:l=U:l=U:l=U:l=0000:l=0:l=0:l=0000000000:l=0000000000:l=0:lll=UUUlll00UUl0UlUllllUlUllUlUU-l-l\"", + "maps.google.com": "0U_UUU=0000-00-00-00; UUU=000=ll-lll0U0l00UlUUllUUllllUUUlU0UlUUUlUUlU0UUUl0UUUlll0Ull0UlUl00lUUllUlUU0lUl0Ul_lllUUllUlUUUl0UU0UU0l0-00l0U0U0-0UlUllUl_UUUll00l0UlUllU0UUUUllUllUUlllUllllUU0llUlUllUUlll", + "microsoft.com": "llUllllUllllll=0; UUUU=000000U000U000U0000U0000000U0000; U-UU-UUUUUUUU=lll=00000l0%2200000l0%22llllll000l0%2200000lll%22llllllllllll000%22lllllllllll%22llllllllllllllll%22llllllllllllllll%22llllllllllllllllllllll%22llllllllllllllllll%22lll-lll-lllll0l0ll%22llllllllllllll%22lllllllllllllllll&lll=00l0000l-lll0-000l-llll-00l0000000ll; U-UU-Ulll=0; lllll_UllUU=0000000000~ll=00~ll=00ll0lll0l00l000000l0ll000ll000l; lllll_UllUU=0000000000~ll=00~ll=00ll0lll0l00l000000l0ll000ll000l", + "play.google.com": "UUU=000=lUUlUlU0UlUlUl0UU0UUUlU0UUlllUllUUUllUUU-Ul00lUUlUU0lUU_lU_lUUUUlUUUUUllUUl-UUl0l0U_lUlUlU0U000llUU_llUlllUl-lUUllUlUlU0lUUlUU0lUllUUlUUlllUUUl0_lllUllUU-llU0ll0U0U0UlU0Ul", + "plus.google.com": "__Ulll-UUUU=0:ll0U0lUl0lUlUUUlUlUlUllUllUlUl:lllUU0llUl00UUU0", + "sites.google.com": "__Ulll-UUUU=0:lll0l00lll0lUllll-l0UU0UlUllll:l0UUUUU0UlUUllUl", + "support.google.com": "UUU=000=lUlU00UlllllUUl0llUUll0lll0llll0lUlUlUl-0llUUUlUlllUUllU_llU00llllllUUUllUlUUlUlUlUlUlUllU-U_ll-0lUUUUlUUll0Ul0ll0UUUU0UUUU0llU-UllUUUlUl0U0lUUl0UlUUllUl0lllllUllUllUlU0ll; UUU=000=lUlU00UlllllUUl0llUUll0lll0llll0lUlUlUl-0llUUUlUlllUUllU_llU00llllllUUUllUlUUlUlUlUlUlUllU-U_ll-0lUUUUlUUll0Ul0ll0UUUU0UUUU0llU-UllUUUlUl0U0lUUl0UlUUllUl0lllllUllUllUlU0ll", + "www.google.com": "0U_UUU=0000-00-00-00; UUU=000=UlU0UlUlU0-lllUUUUlUU0lUlUUUUUUUUUlll-00l-0U0UUlUlUllUUlUUUl0_UUlUU0lll0UlllllUUUlU0UlUl0U0UU_0l-lU0UUUllU_lUUUlUlU_lU0llU0UlUllllllUUUlUl0UUl0lUU0lUUlUllUUlUUllUllUllUUUU", + "youtu.be": "UUU=0; UUU=UUU000lU0UU; UUUUUUU_UUUU0_UUUU=UUlUU0UUU0l", + "youtube.com": "UUU=0; UUU=0l00U0lUUlU; UUUUUUU_UUUU0_UUUU=lUlUllUUUlU" } diff --git a/package.json b/package.json index cd40d0d..b53db99 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "eslint-plugin-markdown": "2.2.1", "mocha": "9.2.0", "nyc": "15.1.0", - "top-sites": "1.1.85" + "top-sites": "1.1.87" }, "files": [ "HISTORY.md", From b9b8d637741ec3d5f1f81a10db968bf827502be0 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sat, 12 Feb 2022 23:05:00 -0500 Subject: [PATCH 092/159] build: Node.js@17.5 --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7de5651..c60d28f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -122,7 +122,7 @@ jobs: node-version: "16.14" - name: Node.js 17.x - node-version: "17.4" + node-version: "17.5" steps: - uses: actions/checkout@v2 From 7bce6c60a5d9e969f07afe6ec3afc27b504c8a0d Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Tue, 1 Mar 2022 01:22:00 -0500 Subject: [PATCH 093/159] build: mocha@9.2.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b53db99..548bc86 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "benchmark": "2.1.4", "eslint": "7.32.0", "eslint-plugin-markdown": "2.2.1", - "mocha": "9.2.0", + "mocha": "9.2.1", "nyc": "15.1.0", "top-sites": "1.1.87" }, From a35632aec32bf66674fd75962700ffb6604ee6ac Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Tue, 1 Mar 2022 01:25:00 -0500 Subject: [PATCH 094/159] build: top-sites@1.1.89 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 548bc86..f03f09a 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "eslint-plugin-markdown": "2.2.1", "mocha": "9.2.1", "nyc": "15.1.0", - "top-sites": "1.1.87" + "top-sites": "1.1.89" }, "files": [ "HISTORY.md", From a313c75c8c81f57940d17165f2551e48cedbfef1 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 14 Mar 2022 23:40:23 -0400 Subject: [PATCH 095/159] build: Node.js@17.7 --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c60d28f..0181794 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -122,7 +122,7 @@ jobs: node-version: "16.14" - name: Node.js 17.x - node-version: "17.5" + node-version: "17.7" steps: - uses: actions/checkout@v2 From 04ddf868601f2460fc11bbbcb9560d4e0c360cb7 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 23 Mar 2022 23:26:08 -0400 Subject: [PATCH 096/159] build: mocha@9.2.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f03f09a..dbf44cd 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "benchmark": "2.1.4", "eslint": "7.32.0", "eslint-plugin-markdown": "2.2.1", - "mocha": "9.2.1", + "mocha": "9.2.2", "nyc": "15.1.0", "top-sites": "1.1.89" }, From 0e1a20f8b0da82709a30304c1ec1d15247b2a7a6 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 23 Mar 2022 23:30:39 -0400 Subject: [PATCH 097/159] docs: update samesite spec link --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index f8389ff..0acb659 100644 --- a/README.md +++ b/README.md @@ -114,7 +114,7 @@ is considered the ["default path"][rfc-6265-5.1.4]. ##### sameSite -Specifies the `boolean` or `string` to be the value for the [`SameSite` `Set-Cookie` attribute][rfc-6265bis-03-4.1.2.7]. +Specifies the `boolean` or `string` to be the value for the [`SameSite` `Set-Cookie` attribute][rfc-6265bis-09-5.4.7]. - `true` will set the `SameSite` attribute to `Strict` for strict same site enforcement. - `false` will not set the `SameSite` attribute. @@ -123,7 +123,7 @@ Specifies the `boolean` or `string` to be the value for the [`SameSite` `Set-Coo - `'strict'` will set the `SameSite` attribute to `Strict` for strict same site enforcement. More information about the different enforcement levels can be found in -[the specification][rfc-6265bis-03-4.1.2.7]. +[the specification][rfc-6265bis-09-5.4.7]. **note** This is an attribute that has not yet been fully standardized, and may change in the future. This also means many clients may ignore this attribute until they understand it. @@ -258,9 +258,9 @@ $ npm run bench ## References - [RFC 6265: HTTP State Management Mechanism][rfc-6265] -- [Same-site Cookies][rfc-6265bis-03-4.1.2.7] +- [Same-site Cookies][rfc-6265bis-09-5.4.7] -[rfc-6265bis-03-4.1.2.7]: https://tools.ietf.org/html/draft-ietf-httpbis-rfc6265bis-03#section-4.1.2.7 +[rfc-6265bis-09-5.4.7]: https://tools.ietf.org/html/draft-ietf-httpbis-rfc6265bis-09#section-5.4.7 [rfc-6265]: https://tools.ietf.org/html/rfc6265 [rfc-6265-5.1.4]: https://tools.ietf.org/html/rfc6265#section-5.1.4 [rfc-6265-5.2.1]: https://tools.ietf.org/html/rfc6265#section-5.2.1 From 16ded6894d38d653b5c7c6ad34f6ea0a1e6c0938 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 23 Mar 2022 23:41:13 -0400 Subject: [PATCH 098/159] Add priority option closes #138 --- HISTORY.md | 5 +++++ README.md | 15 +++++++++++++++ index.js | 20 ++++++++++++++++++++ test/serialize.js | 17 +++++++++++++++++ 4 files changed, 57 insertions(+) diff --git a/HISTORY.md b/HISTORY.md index 2d21760..985e359 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,3 +1,8 @@ +unreleased +========== + + * Add `priority` option + 0.4.2 / 2022-02-02 ================== diff --git a/README.md b/README.md index 0acb659..76f17d0 100644 --- a/README.md +++ b/README.md @@ -112,6 +112,20 @@ so if both are set, they should point to the same date and time. Specifies the value for the [`Path` `Set-Cookie` attribute][rfc-6265-5.2.4]. By default, the path is considered the ["default path"][rfc-6265-5.1.4]. +##### priority + +Specifies the `string` to be the value for the [`Priority` `Set-Cookie` attribute][rfc-west-cookie-priority-00-4.1]. + + - `'low'` will set the `Priority` attribute to `Low`. + - `'medium'` will set the `Priority` attribute to `Medium`, the default priority when not set. + - `'high'` will set the `Priority` attribute to `High`. + +More information about the different priority levels can be found in +[the specification][rfc-west-cookie-priority-00-4.1]. + +**note** This is an attribute that has not yet been fully standardized, and may change in the future. +This also means many clients may ignore this attribute until they understand it. + ##### sameSite Specifies the `boolean` or `string` to be the value for the [`SameSite` `Set-Cookie` attribute][rfc-6265bis-09-5.4.7]. @@ -260,6 +274,7 @@ $ npm run bench - [RFC 6265: HTTP State Management Mechanism][rfc-6265] - [Same-site Cookies][rfc-6265bis-09-5.4.7] +[rfc-west-cookie-priority-00-4.1]: https://tools.ietf.org/html/draft-west-cookie-priority-00#section-4.1 [rfc-6265bis-09-5.4.7]: https://tools.ietf.org/html/draft-ietf-httpbis-rfc6265bis-09#section-5.4.7 [rfc-6265]: https://tools.ietf.org/html/rfc6265 [rfc-6265-5.1.4]: https://tools.ietf.org/html/rfc6265#section-5.1.4 diff --git a/index.js b/index.js index 55331d9..57d545e 100644 --- a/index.js +++ b/index.js @@ -160,6 +160,26 @@ function serialize(name, val, options) { str += '; Secure'; } + if (opt.priority) { + var priority = typeof opt.priority === 'string' + ? opt.priority.toLowerCase() + : opt.priority + + switch (priority) { + case 'low': + str += '; Priority=Low' + break + case 'medium': + str += '; Priority=Medium' + break + case 'high': + str += '; Priority=High' + break + default: + throw new TypeError('option priority is invalid') + } + } + if (opt.sameSite) { var sameSite = typeof opt.sameSite === 'string' ? opt.sameSite.toLowerCase() : opt.sameSite; diff --git a/test/serialize.js b/test/serialize.js index 92bbb7e..57ac661 100644 --- a/test/serialize.js +++ b/test/serialize.js @@ -69,6 +69,23 @@ test('expires', function() { }), /option expires is invalid/); }); +test('priority', function () { + assert.equal(cookie.serialize('foo', 'bar', { priority: 'Low' }), 'foo=bar; Priority=Low') + assert.equal(cookie.serialize('foo', 'bar', { priority: 'loW' }), 'foo=bar; Priority=Low') + assert.equal(cookie.serialize('foo', 'bar', { priority: 'Medium' }), 'foo=bar; Priority=Medium') + assert.equal(cookie.serialize('foo', 'bar', { priority: 'medium' }), 'foo=bar; Priority=Medium') + assert.equal(cookie.serialize('foo', 'bar', { priority: 'High' }), 'foo=bar; Priority=High') + assert.equal(cookie.serialize('foo', 'bar', { priority: 'HIGH' }), 'foo=bar; Priority=High') + + assert.throws(cookie.serialize.bind(cookie, 'foo', 'bar', { + priority: 'foo' + }), /option priority is invalid/) + + assert.throws(cookie.serialize.bind(cookie, 'foo', 'bar', { + priority: 42 + }), /option priority is invalid/) +}) + test('sameSite', function() { assert.equal(cookie.serialize('foo', 'bar', { sameSite: true }), 'foo=bar; SameSite=Strict') assert.equal(cookie.serialize('foo', 'bar', { sameSite: 'Strict' }), 'foo=bar; SameSite=Strict') From 02953b0069945fde2efa9292135d091919ffcbec Mon Sep 17 00:00:00 2001 From: Tobias Speicher Date: Mon, 21 Mar 2022 06:20:36 +0100 Subject: [PATCH 099/159] bench: remove deprecated String.prototype.substr closes #137 --- benchmark/parse-top.js | 2 +- benchmark/parse.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/benchmark/parse-top.js b/benchmark/parse-top.js index 924f45f..eebfdec 100644 --- a/benchmark/parse-top.js +++ b/benchmark/parse-top.js @@ -43,5 +43,5 @@ function gencookies (num) { str += '; foo' + i + '=bar' } - return str.substr(2) + return str.slice(2) } diff --git a/benchmark/parse.js b/benchmark/parse.js index 5310230..e9c3c1d 100644 --- a/benchmark/parse.js +++ b/benchmark/parse.js @@ -70,5 +70,5 @@ function gencookies (num) { str += '; foo' + i + '=bar' } - return str.substr(2) + return str.slice(2) } From 7fab32ed0d5d81436beee70d06e64a974f6bf568 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 28 Mar 2022 21:41:18 -0400 Subject: [PATCH 100/159] build: Node.js@17.8 --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0181794..8921a6b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -122,7 +122,7 @@ jobs: node-version: "16.14" - name: Node.js 17.x - node-version: "17.7" + node-version: "17.8" steps: - uses: actions/checkout@v2 From 042073f1d679b9c7fb7d64660d3c6d372bd1f468 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Tue, 29 Mar 2022 17:25:05 -0400 Subject: [PATCH 101/159] Fix expires option to reject invalid dates --- HISTORY.md | 1 + index.js | 19 +++++++++++++++++-- test/serialize.js | 4 ++++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index 985e359..f58a165 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -2,6 +2,7 @@ unreleased ========== * Add `priority` option + * Fix `expires` option to reject invalid dates 0.4.2 / 2022-02-02 ================== diff --git a/index.js b/index.js index 57d545e..31f6c7d 100644 --- a/index.js +++ b/index.js @@ -20,6 +20,7 @@ exports.serialize = serialize; * @private */ +var __toString = Object.prototype.toString var decode = decodeURIComponent; var encode = encodeURIComponent; @@ -145,11 +146,13 @@ function serialize(name, val, options) { } if (opt.expires) { - if (typeof opt.expires.toUTCString !== 'function') { + var expires = opt.expires + + if (!isDate(expires) || isNaN(expires.valueOf())) { throw new TypeError('option expires is invalid'); } - str += '; Expires=' + opt.expires.toUTCString(); + str += '; Expires=' + expires.toUTCString() } if (opt.httpOnly) { @@ -205,6 +208,18 @@ function serialize(name, val, options) { return str; } +/** + * Determine if value is a Date. + * + * @param {*} val + * @private + */ + +function isDate (val) { + return __toString.call(val) === '[object Date]' || + val instanceof Date +} + /** * Try decoding a string using a decoding function. * diff --git a/test/serialize.js b/test/serialize.js index 57ac661..06c8207 100644 --- a/test/serialize.js +++ b/test/serialize.js @@ -67,6 +67,10 @@ test('expires', function() { assert.throws(cookie.serialize.bind(cookie, 'foo', 'bar', { expires: Date.now() }), /option expires is invalid/); + + assert.throws(cookie.serialize.bind(cookie, 'foo', 'bar', { + expires: new Date(NaN) + }), /option expires is invalid/) }); test('priority', function () { From f3645853a20782ff8dc8a96f2c031b055b2bd987 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Tue, 29 Mar 2022 20:32:48 -0400 Subject: [PATCH 102/159] tests: refactor to standard mocha api --- package.json | 3 +- test/parse.js | 115 ++++++++--------- test/serialize.js | 310 ++++++++++++++++++++++++++++------------------ 3 files changed, 246 insertions(+), 182 deletions(-) diff --git a/package.json b/package.json index dbf44cd..2837a4e 100644 --- a/package.json +++ b/package.json @@ -19,6 +19,7 @@ "eslint-plugin-markdown": "2.2.1", "mocha": "9.2.2", "nyc": "15.1.0", + "safe-buffer": "5.2.1", "top-sites": "1.1.89" }, "files": [ @@ -33,7 +34,7 @@ "scripts": { "bench": "node benchmark/index.js", "lint": "eslint .", - "test": "mocha --reporter spec --bail --check-leaks --ui qunit test/", + "test": "mocha --reporter spec --bail --check-leaks test/", "test-ci": "nyc --reporter=lcov --reporter=text npm test", "test-cov": "nyc --reporter=html --reporter=text npm test", "update-bench": "node scripts/update-benchmark.js", diff --git a/test/parse.js b/test/parse.js index f19f3b6..2e83bb0 100644 --- a/test/parse.js +++ b/test/parse.js @@ -1,65 +1,60 @@ var assert = require('assert'); +var Buffer = require('safe-buffer').Buffer var cookie = require('..'); -suite('parse'); - -test('argument validation', function() { - assert.throws(cookie.parse.bind(), /argument str must be a string/); - assert.throws(cookie.parse.bind(null, 42), /argument str must be a string/); -}); - -test('basic', function() { - assert.deepEqual(cookie.parse('foo=bar'), { foo: 'bar' }) - assert.deepEqual(cookie.parse('foo=123'), { foo: '123' }) -}); - -test('ignore spaces', function() { - assert.deepEqual(cookie.parse('FOO = bar; baz = raz'), - { FOO: 'bar', baz: 'raz' }) -}); - -test('escaping', function() { - assert.deepEqual(cookie.parse('foo="bar=123456789&name=Magic+Mouse"'), - { foo: 'bar=123456789&name=Magic+Mouse' }) - - assert.deepEqual(cookie.parse('email=%20%22%2c%3b%2f'), { email: ' ",;/' }) -}); - -test('ignore escaping error and return original value', function() { - assert.deepEqual(cookie.parse('foo=%1;bar=bar'), { foo: '%1', bar: 'bar' }) -}); - -test('ignore non values', function() { - assert.deepEqual(cookie.parse('foo=%1;bar=bar;HttpOnly;Secure'), - { foo: '%1', bar: 'bar' }) -}); - -test('unencoded', function() { - assert.deepEqual(cookie.parse('foo="bar=123456789&name=Magic+Mouse"', { - decode: function (v) { return v } - }), { foo: 'bar=123456789&name=Magic+Mouse' }) - - assert.deepEqual(cookie.parse('email=%20%22%2c%3b%2f', { - decode: function (v) { return v } - }), { email: '%20%22%2c%3b%2f' }) -}); - -test('dates', function() { - assert.deepEqual(cookie.parse('priority=true; expires=Wed, 29 Jan 2014 17:43:25 GMT; Path=/', { - decode: function (v) { return v } - }), { priority: 'true', Path: '/', expires: 'Wed, 29 Jan 2014 17:43:25 GMT' }) -}); - -test('missing value', function() { - assert.deepEqual(cookie.parse('foo; bar=1; fizz= ; buzz=2', { - decode: function (v) { return v } - }), { bar: '1', fizz: '', buzz: '2' }) -}); - -test('assign only once', function() { - assert.deepEqual(cookie.parse('foo=%1;bar=bar;foo=boo'), { foo: '%1', bar: 'bar' }) - assert.deepEqual(cookie.parse('foo=false;bar=bar;foo=true'), { foo: 'false', bar: 'bar' }) - assert.deepEqual(cookie.parse('foo=;bar=bar;foo=boo'), { foo: '', bar: 'bar' }) -}); +describe('cookie.parse(str)', function () { + it('should throw with no arguments', function () { + assert.throws(cookie.parse.bind(), /argument str must be a string/) + }) + + it('should throw when not a string', function () { + assert.throws(cookie.parse.bind(null, 42), /argument str must be a string/) + }) + + it('should parse cookie string to object', function () { + assert.deepEqual(cookie.parse('foo=bar'), { foo: 'bar' }) + assert.deepEqual(cookie.parse('foo=123'), { foo: '123' }) + }) + + it('should ignore OWS', function () { + assert.deepEqual(cookie.parse('FOO = bar; baz = raz'), + { FOO: 'bar', baz: 'raz' }) + }) + + it('should parse cookie with empty value', function () { + assert.deepEqual(cookie.parse('foo= ; bar='), { foo: '', bar: '' }) + }) + + it('should URL-decode values', function () { + assert.deepEqual(cookie.parse('foo="bar=123456789&name=Magic+Mouse"'), + { foo: 'bar=123456789&name=Magic+Mouse' }) + + assert.deepEqual(cookie.parse('email=%20%22%2c%3b%2f'), { email: ' ",;/' }) + }) + + it('should return original value on escape error', function () { + assert.deepEqual(cookie.parse('foo=%1;bar=bar'), { foo: '%1', bar: 'bar' }) + }) + + it('should ignore cookies without value', function () { + assert.deepEqual(cookie.parse('foo=bar;fizz ; buzz'), { foo: 'bar' }) + }) + + it('should ignore duplicate cookies', function () { + assert.deepEqual(cookie.parse('foo=%1;bar=bar;foo=boo'), { foo: '%1', bar: 'bar' }) + assert.deepEqual(cookie.parse('foo=false;bar=bar;foo=true'), { foo: 'false', bar: 'bar' }) + assert.deepEqual(cookie.parse('foo=;bar=bar;foo=boo'), { foo: '', bar: 'bar' }) + }) +}) + +describe('cookie.parse(str, options)', function () { + describe('with "decode" option', function () { + it('should specify alternative value decoder', function () { + assert.deepEqual(cookie.parse('foo="YmFy"', { + decode: function (v) { return Buffer.from(v, 'base64').toString() } + }), { foo: 'bar' }) + }) + }) +}) diff --git a/test/serialize.js b/test/serialize.js index 06c8207..6e34590 100644 --- a/test/serialize.js +++ b/test/serialize.js @@ -1,128 +1,196 @@ -// builtin + var assert = require('assert'); +var Buffer = require('safe-buffer').Buffer var cookie = require('..'); -suite('serialize'); - -test('basic', function() { - assert.equal(cookie.serialize('foo', 'bar'), 'foo=bar') - assert.equal(cookie.serialize('foo', 'bar baz'), 'foo=bar%20baz') - assert.equal(cookie.serialize('foo', ''), 'foo=') - assert.throws(cookie.serialize.bind(cookie, 'foo\n', 'bar'), /argument name is invalid/); - assert.throws(cookie.serialize.bind(cookie, 'foo\u280a', 'bar'), /argument name is invalid/); - assert.throws(cookie.serialize.bind(cookie, 'foo', 'bar', {encode: 42}), /option encode is invalid/); -}); - -test('path', function() { - assert.equal(cookie.serialize('foo', 'bar', { path: '/' }), 'foo=bar; Path=/') - assert.throws(cookie.serialize.bind(cookie, 'foo', 'bar', { - path: '/\n' - }), /option path is invalid/); -}); - -test('secure', function() { - assert.equal(cookie.serialize('foo', 'bar', { secure: true }), 'foo=bar; Secure') - assert.equal(cookie.serialize('foo', 'bar', { secure: false }), 'foo=bar') -}); - -test('domain', function() { - assert.equal(cookie.serialize('foo', 'bar', { domain: 'example.com' }), 'foo=bar; Domain=example.com') - assert.throws(cookie.serialize.bind(cookie, 'foo', 'bar', { - domain: 'example.com\n' - }), /option domain is invalid/); -}); - -test('httpOnly', function() { - assert.equal(cookie.serialize('foo', 'bar', { httpOnly: true }), 'foo=bar; HttpOnly') -}); - -test('maxAge', function() { - assert.throws(function () { - cookie.serialize('foo', 'bar', { - maxAge: 'buzz' - }); - }, /option maxAge is invalid/) - - assert.throws(function () { - cookie.serialize('foo', 'bar', { - maxAge: Infinity - }) - }, /option maxAge is invalid/) - - assert.equal(cookie.serialize('foo', 'bar', { maxAge: 1000 }), 'foo=bar; Max-Age=1000') - assert.equal(cookie.serialize('foo', 'bar', { maxAge: '1000' }), 'foo=bar; Max-Age=1000') - assert.equal(cookie.serialize('foo', 'bar', { maxAge: 0 }), 'foo=bar; Max-Age=0') - assert.equal(cookie.serialize('foo', 'bar', { maxAge: '0' }), 'foo=bar; Max-Age=0') - assert.equal(cookie.serialize('foo', 'bar', { maxAge: null }), 'foo=bar') - assert.equal(cookie.serialize('foo', 'bar', { maxAge: undefined }), 'foo=bar') - assert.equal(cookie.serialize('foo', 'bar', { maxAge: 3.14 }), 'foo=bar; Max-Age=3') -}); - -test('expires', function() { - assert.equal(cookie.serialize('foo', 'bar', { - expires: new Date(Date.UTC(2000, 11, 24, 10, 30, 59, 900)) - }), 'foo=bar; Expires=Sun, 24 Dec 2000 10:30:59 GMT') - - assert.throws(cookie.serialize.bind(cookie, 'foo', 'bar', { - expires: Date.now() - }), /option expires is invalid/); - - assert.throws(cookie.serialize.bind(cookie, 'foo', 'bar', { - expires: new Date(NaN) - }), /option expires is invalid/) -}); - -test('priority', function () { - assert.equal(cookie.serialize('foo', 'bar', { priority: 'Low' }), 'foo=bar; Priority=Low') - assert.equal(cookie.serialize('foo', 'bar', { priority: 'loW' }), 'foo=bar; Priority=Low') - assert.equal(cookie.serialize('foo', 'bar', { priority: 'Medium' }), 'foo=bar; Priority=Medium') - assert.equal(cookie.serialize('foo', 'bar', { priority: 'medium' }), 'foo=bar; Priority=Medium') - assert.equal(cookie.serialize('foo', 'bar', { priority: 'High' }), 'foo=bar; Priority=High') - assert.equal(cookie.serialize('foo', 'bar', { priority: 'HIGH' }), 'foo=bar; Priority=High') - - assert.throws(cookie.serialize.bind(cookie, 'foo', 'bar', { - priority: 'foo' - }), /option priority is invalid/) - - assert.throws(cookie.serialize.bind(cookie, 'foo', 'bar', { - priority: 42 - }), /option priority is invalid/) +describe('cookie.serialize(name, value)', function () { + it('should serialize name and value', function () { + assert.equal(cookie.serialize('foo', 'bar'), 'foo=bar') + }) + + it('should URL-encode value', function () { + assert.equal(cookie.serialize('foo', 'bar +baz'), 'foo=bar%20%2Bbaz') + }) + + it('should serialize empty value', function () { + assert.equal(cookie.serialize('foo', ''), 'foo=') + }) + + it('should throw for invalid name', function () { + assert.throws(cookie.serialize.bind(cookie, 'foo\n', 'bar'), /argument name is invalid/) + assert.throws(cookie.serialize.bind(cookie, 'foo\u280a', 'bar'), /argument name is invalid/) + }) }) -test('sameSite', function() { - assert.equal(cookie.serialize('foo', 'bar', { sameSite: true }), 'foo=bar; SameSite=Strict') - assert.equal(cookie.serialize('foo', 'bar', { sameSite: 'Strict' }), 'foo=bar; SameSite=Strict') - assert.equal(cookie.serialize('foo', 'bar', { sameSite: 'strict' }), 'foo=bar; SameSite=Strict') - assert.equal(cookie.serialize('foo', 'bar', { sameSite: 'Lax' }), 'foo=bar; SameSite=Lax') - assert.equal(cookie.serialize('foo', 'bar', { sameSite: 'lax' }), 'foo=bar; SameSite=Lax') - assert.equal(cookie.serialize('foo', 'bar', { sameSite: 'None' }), 'foo=bar; SameSite=None') - assert.equal(cookie.serialize('foo', 'bar', { sameSite: 'none' }), 'foo=bar; SameSite=None') - assert.equal(cookie.serialize('foo', 'bar', { sameSite: false }), 'foo=bar') - - assert.throws(cookie.serialize.bind(cookie, 'foo', 'bar', { - sameSite: 'foo' - }), /option sameSite is invalid/); -}); - -test('escaping', function() { - assert.deepEqual(cookie.serialize('cat', '+ '), 'cat=%2B%20') -}); - -test('parse->serialize', function() { - assert.deepEqual(cookie.parse(cookie.serialize('cat', 'foo=123&name=baz five')), - { cat: 'foo=123&name=baz five' }) - - assert.deepEqual(cookie.parse(cookie.serialize('cat', ' ";/')), - { cat: ' ";/' }) -}); - -test('unencoded', function() { - assert.deepEqual(cookie.serialize('cat', '+ ', { - encode: function(value) { return value; } - }), 'cat=+ ') - - assert.throws(cookie.serialize.bind(cookie, 'cat', '+ \n', { - encode: function(value) { return value; } - }), /argument val is invalid/); +describe('cookie.serialize(name, value, options)', function () { + describe('with "domain" option', function () { + it('should serialize domain', function () { + assert.equal(cookie.serialize('foo', 'bar', { domain: 'example.com' }), + 'foo=bar; Domain=example.com') + }) + + it('should throw for invalid value', function () { + assert.throws(cookie.serialize.bind(cookie, 'foo', 'bar', { domain: 'example.com\n' }), + /option domain is invalid/) + }) + }) + + describe('with "encode" option', function () { + it('should throw on non-function value', function () { + assert.throws(cookie.serialize.bind(cookie, 'foo', 'bar', { encode: 42 }), + /option encode is invalid/) + }) + + it('should specify alternative value encoder', function () { + assert.deepEqual(cookie.serialize('foo', 'bar', { + encode: function (v) { return Buffer.from(v, 'utf8').toString('base64') } + }), 'foo=YmFy') + }) + + it('should throw when returned value is invalid', function () { + assert.throws(cookie.serialize.bind(cookie, 'foo', '+ \n', { + encode: function (v) { return v } + }), /argument val is invalid/) + }) + }) + + describe('with "expires" option', function () { + it('should throw on non-Date value', function () { + assert.throws(cookie.serialize.bind(cookie, 'foo', 'bar', { expires: 42 }), + /option expires is invalid/) + }) + + it('should throw on invalid date', function () { + assert.throws(cookie.serialize.bind(cookie, 'foo', 'bar', { expires: new Date(NaN) }), + /option expires is invalid/) + }) + + it('should set expires to given date', function () { + assert.equal(cookie.serialize('foo', 'bar', { + expires: new Date(Date.UTC(2000, 11, 24, 10, 30, 59, 900)) + }), 'foo=bar; Expires=Sun, 24 Dec 2000 10:30:59 GMT') + }) + }) + + describe('with "httpOnly" option', function () { + it('should include httpOnly flag when true', function () { + assert.equal(cookie.serialize('foo', 'bar', { httpOnly: true }), 'foo=bar; HttpOnly') + }) + + it('should not include httpOnly flag when false', function () { + assert.equal(cookie.serialize('foo', 'bar', { httpOnly: false }), 'foo=bar') + }) + }) + + describe('with "maxAge" option', function () { + it('should throw when not a number', function () { + assert.throws(function () { + cookie.serialize('foo', 'bar', { maxAge: 'buzz' }) + }, /option maxAge is invalid/) + }) + + it('should throw when Infinity', function () { + assert.throws(function () { + cookie.serialize('foo', 'bar', { maxAge: Infinity }) + }, /option maxAge is invalid/) + }) + + it('should set max-age to value', function () { + assert.equal(cookie.serialize('foo', 'bar', { maxAge: 1000 }), 'foo=bar; Max-Age=1000') + assert.equal(cookie.serialize('foo', 'bar', { maxAge: '1000' }), 'foo=bar; Max-Age=1000') + assert.equal(cookie.serialize('foo', 'bar', { maxAge: 0 }), 'foo=bar; Max-Age=0') + assert.equal(cookie.serialize('foo', 'bar', { maxAge: '0' }), 'foo=bar; Max-Age=0') + }) + + it('should set max-age to integer value', function () { + assert.equal(cookie.serialize('foo', 'bar', { maxAge: 3.14 }), 'foo=bar; Max-Age=3') + assert.equal(cookie.serialize('foo', 'bar', { maxAge: 3.99 }), 'foo=bar; Max-Age=3') + }) + + it('should not set when null', function () { + assert.equal(cookie.serialize('foo', 'bar', { maxAge: null }), 'foo=bar') + }) + }) + + describe('with "path" option', function () { + it('should serialize path', function () { + assert.equal(cookie.serialize('foo', 'bar', { path: '/' }), 'foo=bar; Path=/') + }) + + it('should throw for invalid value', function () { + assert.throws(cookie.serialize.bind(cookie, 'foo', 'bar', { path: '/\n' }), + /option path is invalid/) + }) + }) + + describe('with "priority" option', function () { + it('should throw on invalid priority', function () { + assert.throws(function () { + cookie.serialize('foo', 'bar', { priority: 'foo' }) + }, /option priority is invalid/) + }) + + it('should throw on non-string', function () { + assert.throws(function () { + cookie.serialize('foo', 'bar', { priority: 42 }) + }, /option priority is invalid/) + }) + + it('should set priority low', function () { + assert.equal(cookie.serialize('foo', 'bar', { priority: 'Low' }), 'foo=bar; Priority=Low') + assert.equal(cookie.serialize('foo', 'bar', { priority: 'loW' }), 'foo=bar; Priority=Low') + }) + + it('should set priority medium', function () { + assert.equal(cookie.serialize('foo', 'bar', { priority: 'Medium' }), 'foo=bar; Priority=Medium') + assert.equal(cookie.serialize('foo', 'bar', { priority: 'medium' }), 'foo=bar; Priority=Medium') + }) + + it('should set priority high', function () { + assert.equal(cookie.serialize('foo', 'bar', { priority: 'High' }), 'foo=bar; Priority=High') + assert.equal(cookie.serialize('foo', 'bar', { priority: 'HIGH' }), 'foo=bar; Priority=High') + }) + }) + + describe('with "sameSite" option', function () { + it('should throw on invalid sameSite', function () { + assert.throws(function () { + cookie.serialize('foo', 'bar', { sameSite: 'foo' }) + }, /option sameSite is invalid/) + }) + + it('should set sameSite strict', function () { + assert.equal(cookie.serialize('foo', 'bar', { sameSite: 'Strict' }), 'foo=bar; SameSite=Strict') + assert.equal(cookie.serialize('foo', 'bar', { sameSite: 'strict' }), 'foo=bar; SameSite=Strict') + }) + + it('should set sameSite lax', function () { + assert.equal(cookie.serialize('foo', 'bar', { sameSite: 'Lax' }), 'foo=bar; SameSite=Lax') + assert.equal(cookie.serialize('foo', 'bar', { sameSite: 'lax' }), 'foo=bar; SameSite=Lax') + }) + + it('should set sameSite none', function () { + assert.equal(cookie.serialize('foo', 'bar', { sameSite: 'None' }), 'foo=bar; SameSite=None') + assert.equal(cookie.serialize('foo', 'bar', { sameSite: 'none' }), 'foo=bar; SameSite=None') + }) + + it('should set sameSite strict when true', function () { + assert.equal(cookie.serialize('foo', 'bar', { sameSite: true }), 'foo=bar; SameSite=Strict') + }) + + it('should not set sameSite when false', function () { + assert.equal(cookie.serialize('foo', 'bar', { sameSite: false }), 'foo=bar') + }) + }) + + describe('with "secure" option', function () { + it('should include secure flag when true', function () { + assert.equal(cookie.serialize('foo', 'bar', { secure: true }), 'foo=bar; Secure') + }) + + it('should not include secure flag when false', function () { + assert.equal(cookie.serialize('foo', 'bar', { secure: false }), 'foo=bar') + }) + }) }) From e5de9f653118a603ccc450a05f1f82119d1f6bfc Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Tue, 29 Mar 2022 22:41:15 -0400 Subject: [PATCH 103/159] tests: add additional parse test --- test/parse.js | 1 + 1 file changed, 1 insertion(+) diff --git a/test/parse.js b/test/parse.js index 2e83bb0..76229ca 100644 --- a/test/parse.js +++ b/test/parse.js @@ -40,6 +40,7 @@ describe('cookie.parse(str)', function () { it('should ignore cookies without value', function () { assert.deepEqual(cookie.parse('foo=bar;fizz ; buzz'), { foo: 'bar' }) + assert.deepEqual(cookie.parse(' fizz; foo= bar'), { foo: 'bar' }) }) it('should ignore duplicate cookies', function () { From 624b4e26e8bd9f0ecbdebe68ba585fc9744ddb10 Mon Sep 17 00:00:00 2001 From: Justin Ridgewell Date: Thu, 10 May 2018 21:23:55 -0400 Subject: [PATCH 104/159] pref: remove slow string split in parse closes #77 --- HISTORY.md | 1 + README.md | 42 +++++++++++++++++++++--------------------- index.js | 33 ++++++++++++++++++++++----------- 3 files changed, 44 insertions(+), 32 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index f58a165..b059d52 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -3,6 +3,7 @@ unreleased * Add `priority` option * Fix `expires` option to reject invalid dates + * pref: remove slow string split in parse 0.4.2 / 2022-02-02 ================== diff --git a/README.md b/README.md index 76f17d0..d9be213 100644 --- a/README.md +++ b/README.md @@ -239,21 +239,21 @@ $ npm run bench 15 tests completed. - parse apple.com x 634,820 ops/sec ±0.59% (187 runs sampled) - parse cloudflare.com x 215,701 ops/sec ±1.73% (178 runs sampled) - parse docs.google.com x 271,466 ops/sec ±2.50% (184 runs sampled) - parse drive.google.com x 301,338 ops/sec ±0.69% (186 runs sampled) - parse en.wikipedia.org x 160,666 ops/sec ±1.00% (186 runs sampled) - parse linkedin.com x 95,545 ops/sec ±2.83% (177 runs sampled) - parse maps.google.com x 163,629 ops/sec ±1.26% (185 runs sampled) - parse microsoft.com x 86,596 ops/sec ±0.72% (187 runs sampled) - parse play.google.com x 221,059 ops/sec ±0.79% (187 runs sampled) - parse plus.google.com x 302,712 ops/sec ±0.61% (185 runs sampled) - parse sites.google.com x 309,551 ops/sec ±0.43% (190 runs sampled) - parse support.google.com x 216,781 ops/sec ±0.44% (187 runs sampled) - parse www.google.com x 165,432 ops/sec ±1.03% (188 runs sampled) - parse youtu.be x 293,169 ops/sec ±1.79% (178 runs sampled) - parse youtube.com x 278,482 ops/sec ±0.60% (179 runs sampled) + parse apple.com x 1,247,936 ops/sec ±0.86% (186 runs sampled) + parse cloudflare.com x 252,012 ops/sec ±0.94% (187 runs sampled) + parse docs.google.com x 325,788 ops/sec ±1.64% (186 runs sampled) + parse drive.google.com x 345,108 ops/sec ±0.73% (185 runs sampled) + parse en.wikipedia.org x 177,795 ops/sec ±1.33% (187 runs sampled) + parse linkedin.com x 111,281 ops/sec ±0.75% (189 runs sampled) + parse maps.google.com x 181,924 ops/sec ±0.90% (187 runs sampled) + parse microsoft.com x 89,373 ops/sec ±0.90% (189 runs sampled) + parse play.google.com x 252,671 ops/sec ±0.76% (189 runs sampled) + parse plus.google.com x 338,954 ops/sec ±0.75% (188 runs sampled) + parse sites.google.com x 338,758 ops/sec ±0.60% (189 runs sampled) + parse support.google.com x 235,755 ops/sec ±0.80% (189 runs sampled) + parse www.google.com x 180,591 ops/sec ±0.83% (187 runs sampled) + parse youtu.be x 335,329 ops/sec ±1.23% (186 runs sampled) + parse youtube.com x 336,261 ops/sec ±0.78% (186 runs sampled) > node benchmark/parse.js @@ -261,12 +261,12 @@ $ npm run bench 6 tests completed. - simple x 546,939 ops/sec ±1.69% (183 runs sampled) - decode x 411,702 ops/sec ±0.46% (188 runs sampled) - unquote x 412,031 ops/sec ±1.86% (183 runs sampled) - duplicates x 288,746 ops/sec ±0.44% (183 runs sampled) - 10 cookies x 105,597 ops/sec ±0.41% (190 runs sampled) - 100 cookies x 10,534 ops/sec ±0.41% (190 runs sampled) + simple x 1,030,578 ops/sec ±0.94% (187 runs sampled) + decode x 584,782 ops/sec ±1.16% (187 runs sampled) + unquote x 638,382 ops/sec ±1.05% (185 runs sampled) + duplicates x 383,158 ops/sec ±2.11% (185 runs sampled) + 10 cookies x 110,175 ops/sec ±0.78% (187 runs sampled) + 100 cookies x 10,609 ops/sec ±0.78% (189 runs sampled) ``` ## References diff --git a/index.js b/index.js index 31f6c7d..f23d48c 100644 --- a/index.js +++ b/index.js @@ -53,31 +53,42 @@ function parse(str, options) { var obj = {} var opt = options || {}; - var pairs = str.split(';') var dec = opt.decode || decode; - for (var i = 0; i < pairs.length; i++) { - var pair = pairs[i]; - var index = pair.indexOf('=') + var index = 0 + while (index < str.length) { + var eqIdx = str.indexOf('=', index) - // skip things that don't look like key=value - if (index < 0) { - continue; + // no more cookie pairs + if (eqIdx === -1) { + break } - var key = pair.substring(0, index).trim() + var endIdx = str.indexOf(';', index) + + if (endIdx === -1) { + endIdx = str.length + } else if (endIdx < eqIdx) { + // backtrack on prior semicolon + index = str.lastIndexOf(';', eqIdx - 1) + 1 + continue + } + + var key = str.slice(index, eqIdx).trim() // only assign once - if (undefined == obj[key]) { - var val = pair.substring(index + 1, pair.length).trim() + if (undefined === obj[key]) { + var val = str.slice(eqIdx + 1, endIdx).trim() // quoted values - if (val[0] === '"') { + if (val.charCodeAt(0) === 0x22) { val = val.slice(1, -1) } obj[key] = tryDecode(val, dec); } + + index = endIdx + 1 } return obj; From 7c65abe3515165b1e06ab3f6c5064e00b06b6e99 Mon Sep 17 00:00:00 2001 From: Justin Ridgewell Date: Fri, 11 May 2018 10:29:31 -0400 Subject: [PATCH 105/159] pref: improve default decode speed closes #77 --- HISTORY.md | 1 + README.md | 42 +++++++++++++++++++++--------------------- index.js | 26 ++++++++++++++++++++++++-- 3 files changed, 46 insertions(+), 23 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index b059d52..5768609 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -3,6 +3,7 @@ unreleased * Add `priority` option * Fix `expires` option to reject invalid dates + * pref: improve default decode speed * pref: remove slow string split in parse 0.4.2 / 2022-02-02 diff --git a/README.md b/README.md index d9be213..c7f2041 100644 --- a/README.md +++ b/README.md @@ -239,21 +239,21 @@ $ npm run bench 15 tests completed. - parse apple.com x 1,247,936 ops/sec ±0.86% (186 runs sampled) - parse cloudflare.com x 252,012 ops/sec ±0.94% (187 runs sampled) - parse docs.google.com x 325,788 ops/sec ±1.64% (186 runs sampled) - parse drive.google.com x 345,108 ops/sec ±0.73% (185 runs sampled) - parse en.wikipedia.org x 177,795 ops/sec ±1.33% (187 runs sampled) - parse linkedin.com x 111,281 ops/sec ±0.75% (189 runs sampled) - parse maps.google.com x 181,924 ops/sec ±0.90% (187 runs sampled) - parse microsoft.com x 89,373 ops/sec ±0.90% (189 runs sampled) - parse play.google.com x 252,671 ops/sec ±0.76% (189 runs sampled) - parse plus.google.com x 338,954 ops/sec ±0.75% (188 runs sampled) - parse sites.google.com x 338,758 ops/sec ±0.60% (189 runs sampled) - parse support.google.com x 235,755 ops/sec ±0.80% (189 runs sampled) - parse www.google.com x 180,591 ops/sec ±0.83% (187 runs sampled) - parse youtu.be x 335,329 ops/sec ±1.23% (186 runs sampled) - parse youtube.com x 336,261 ops/sec ±0.78% (186 runs sampled) + parse apple.com x 3,459,374 ops/sec ±1.29% (185 runs sampled) + parse cloudflare.com x 2,350,288 ops/sec ±0.82% (187 runs sampled) + parse docs.google.com x 2,556,080 ops/sec ±0.98% (186 runs sampled) + parse drive.google.com x 2,579,129 ops/sec ±0.75% (186 runs sampled) + parse en.wikipedia.org x 852,883 ops/sec ±0.75% (187 runs sampled) + parse linkedin.com x 543,323 ops/sec ±0.71% (188 runs sampled) + parse maps.google.com x 1,319,198 ops/sec ±0.88% (187 runs sampled) + parse microsoft.com x 152,365 ops/sec ±1.07% (186 runs sampled) + parse play.google.com x 2,499,181 ops/sec ±0.68% (187 runs sampled) + parse plus.google.com x 2,558,406 ops/sec ±0.77% (187 runs sampled) + parse sites.google.com x 2,560,766 ops/sec ±0.71% (186 runs sampled) + parse support.google.com x 1,548,934 ops/sec ±0.85% (186 runs sampled) + parse www.google.com x 1,350,825 ops/sec ±1.10% (187 runs sampled) + parse youtu.be x 1,047,505 ops/sec ±0.71% (188 runs sampled) + parse youtube.com x 1,046,127 ops/sec ±0.68% (188 runs sampled) > node benchmark/parse.js @@ -261,12 +261,12 @@ $ npm run bench 6 tests completed. - simple x 1,030,578 ops/sec ±0.94% (187 runs sampled) - decode x 584,782 ops/sec ±1.16% (187 runs sampled) - unquote x 638,382 ops/sec ±1.05% (185 runs sampled) - duplicates x 383,158 ops/sec ±2.11% (185 runs sampled) - 10 cookies x 110,175 ops/sec ±0.78% (187 runs sampled) - 100 cookies x 10,609 ops/sec ±0.78% (189 runs sampled) + simple x 3,541,023 ops/sec ±0.81% (186 runs sampled) + decode x 569,051 ops/sec ±0.63% (188 runs sampled) + unquote x 3,031,533 ops/sec ±0.80% (184 runs sampled) + duplicates x 937,600 ops/sec ±0.76% (186 runs sampled) + 10 cookies x 302,703 ops/sec ±1.25% (188 runs sampled) + 100 cookies x 23,559 ops/sec ±0.71% (189 runs sampled) ``` ## References diff --git a/index.js b/index.js index f23d48c..9c3d07d 100644 --- a/index.js +++ b/index.js @@ -21,8 +21,6 @@ exports.serialize = serialize; */ var __toString = Object.prototype.toString -var decode = decodeURIComponent; -var encode = encodeURIComponent; /** * RegExp to match field-content in RFC 7230 sec 3.2 @@ -219,6 +217,30 @@ function serialize(name, val, options) { return str; } +/** + * URL-decode string value. Optimized to skip native call when no %. + * + * @param {string} str + * @returns {string} + */ + +function decode (str) { + return str.indexOf('%') !== -1 + ? decodeURIComponent(str) + : str +} + +/** + * URL-encode value. + * + * @param {string} str + * @returns {string} + */ + +function encode (val) { + return encodeURIComponent(val) +} + /** * Determine if value is a Date. * From 5c50e512c0ba0b128bda91bc258a0eac9e16e029 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 11 Apr 2022 19:00:57 -0400 Subject: [PATCH 106/159] build: Node.js@17.9 --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8921a6b..95edacd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -122,7 +122,7 @@ jobs: node-version: "16.14" - name: Node.js 17.x - node-version: "17.8" + node-version: "17.9" steps: - uses: actions/checkout@v2 From 07ece97f96f43a71e59584407d0b47f90eb025db Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 11 Apr 2022 19:06:57 -0400 Subject: [PATCH 107/159] build: top-sites@1.1.97 --- README.md | 43 ++++++++++++++++++++-------------------- benchmark/parse-top.json | 27 +++++++++++++------------ package.json | 2 +- 3 files changed, 37 insertions(+), 35 deletions(-) diff --git a/README.md b/README.md index c7f2041..5449c3a 100644 --- a/README.md +++ b/README.md @@ -239,21 +239,22 @@ $ npm run bench 15 tests completed. - parse apple.com x 3,459,374 ops/sec ±1.29% (185 runs sampled) - parse cloudflare.com x 2,350,288 ops/sec ±0.82% (187 runs sampled) - parse docs.google.com x 2,556,080 ops/sec ±0.98% (186 runs sampled) - parse drive.google.com x 2,579,129 ops/sec ±0.75% (186 runs sampled) - parse en.wikipedia.org x 852,883 ops/sec ±0.75% (187 runs sampled) - parse linkedin.com x 543,323 ops/sec ±0.71% (188 runs sampled) - parse maps.google.com x 1,319,198 ops/sec ±0.88% (187 runs sampled) - parse microsoft.com x 152,365 ops/sec ±1.07% (186 runs sampled) - parse play.google.com x 2,499,181 ops/sec ±0.68% (187 runs sampled) - parse plus.google.com x 2,558,406 ops/sec ±0.77% (187 runs sampled) - parse sites.google.com x 2,560,766 ops/sec ±0.71% (186 runs sampled) - parse support.google.com x 1,548,934 ops/sec ±0.85% (186 runs sampled) - parse www.google.com x 1,350,825 ops/sec ±1.10% (187 runs sampled) - parse youtu.be x 1,047,505 ops/sec ±0.71% (188 runs sampled) - parse youtube.com x 1,046,127 ops/sec ±0.68% (188 runs sampled) + parse accounts.google.com x 2,421,245 ops/sec ±0.80% (188 runs sampled) + parse apple.com x 2,684,710 ops/sec ±0.59% (189 runs sampled) + parse cloudflare.com x 2,231,418 ops/sec ±0.76% (186 runs sampled) + parse docs.google.com x 2,316,357 ops/sec ±1.28% (187 runs sampled) + parse drive.google.com x 2,363,543 ops/sec ±0.49% (189 runs sampled) + parse en.wikipedia.org x 839,414 ops/sec ±0.53% (189 runs sampled) + parse linkedin.com x 553,797 ops/sec ±0.63% (190 runs sampled) + parse maps.google.com x 1,314,779 ops/sec ±0.72% (189 runs sampled) + parse microsoft.com x 153,783 ops/sec ±0.53% (190 runs sampled) + parse play.google.com x 2,249,574 ops/sec ±0.59% (187 runs sampled) + parse plus.google.com x 2,258,682 ops/sec ±0.60% (188 runs sampled) + parse sites.google.com x 2,247,069 ops/sec ±0.68% (189 runs sampled) + parse support.google.com x 1,456,840 ops/sec ±0.70% (187 runs sampled) + parse www.google.com x 1,046,028 ops/sec ±0.58% (188 runs sampled) + parse youtu.be x 937,428 ops/sec ±1.47% (190 runs sampled) + parse youtube.com x 963,878 ops/sec ±0.59% (190 runs sampled) > node benchmark/parse.js @@ -261,12 +262,12 @@ $ npm run bench 6 tests completed. - simple x 3,541,023 ops/sec ±0.81% (186 runs sampled) - decode x 569,051 ops/sec ±0.63% (188 runs sampled) - unquote x 3,031,533 ops/sec ±0.80% (184 runs sampled) - duplicates x 937,600 ops/sec ±0.76% (186 runs sampled) - 10 cookies x 302,703 ops/sec ±1.25% (188 runs sampled) - 100 cookies x 23,559 ops/sec ±0.71% (189 runs sampled) + simple x 2,745,604 ops/sec ±0.77% (185 runs sampled) + decode x 557,287 ops/sec ±0.60% (188 runs sampled) + unquote x 2,498,475 ops/sec ±0.55% (189 runs sampled) + duplicates x 868,591 ops/sec ±0.89% (187 runs sampled) + 10 cookies x 306,745 ops/sec ±0.49% (190 runs sampled) + 100 cookies x 22,414 ops/sec ±2.38% (182 runs sampled) ``` ## References diff --git a/benchmark/parse-top.json b/benchmark/parse-top.json index 1ae4c1d..37f8677 100644 --- a/benchmark/parse-top.json +++ b/benchmark/parse-top.json @@ -1,17 +1,18 @@ { + "accounts.google.com": "__Ulll-UUUU=0:0U0lUlllUUUl0lUl00UUUUUU0lUlll:l0ll0UlUU0l0lUUU", "apple.com": "lll=UU", - "cloudflare.com": "__ll_ll=lll00UlUlUlll_lUUlUUUl0UllUUUUl0l0UUl0U0UUU-0000000000-0-UU0lllUUUUllU0UUUU0UUl0UU0Ul0Ull0UUll0UlUllUUl0UUU/lUUUUlUUUUUllUlUUlUUUlUllU00l0UllUlll/UUllUlUUllUUl0UUlll", - "docs.google.com": "__Ulll-UUUU=0:UlUU-lU0UUlUU0llUUUl0lllllU0lU:UlUUl0U0UlUUUU0l", - "drive.google.com": "__Ulll-UUUU=0:llllUlUllllU00l0lU0UUllUlllUll:_0lUU0l0lUl-0lUU", + "cloudflare.com": "__ll_ll=lUllUll.0Ul0Ull0UUUU.ll_U0lllUU0UlUll0lUllU-0000000000-0-UUUl+0Ulll0UUUU0U0Ullll0UUUUUlllU0UUUUlUUUlUUUUUUUlUlUUll0l0UlUlUl0Ul000UUlUU0/0l0l0UU0UllUU0U0lU/lllU0lUllU", + "docs.google.com": "__Ulll-UUUU=0:Ulll0UlUUllUlUl0UUlUUlUU0UUUUU:U0U0U0llUU0-0Ul0", + "drive.google.com": "__Ulll-UUUU=0:UUll0UllUUll0lUU0llUUllUllUlll:U0UllUlll-lU0lll", "en.wikipedia.org": "UUU-Ulll-Ulllll=00-Ull-0000; UUU-Ulll-Ulllll-Ulllll=00-Ull-0000; UllUU=UU:UU:Ulllllllllll:00.00:-00.00:l0", - "linkedin.com": "UUUUUUUUUU=llll:0000000000000000000; llll=l=0&llll=ll-ll; lllllll=\"l=0&0lll00l0-0000-0000-0000-lll0ll0l00l0\"; llllllll=\"l=0&00000000000000l000l000-l0ll-00l0-0ll0-0000l0ll0l00UUUUlU-Ul-lllllUUUUUllUUUlUlUUll\"; llll=\"l=UUUU00:l=U:l=U:l=U:l=U:l=0000:l=0:l=0:l=0000000000:l=0000000000:l=0:lll=UUUlll00UUl0UlUllllUlUllUlUU-l-l\"", - "maps.google.com": "0U_UUU=0000-00-00-00; UUU=000=ll-lll0U0l00UlUUllUUllllUUUlU0UlUUUlUUlU0UUUl0UUUlll0Ull0UlUl00lUUllUlUU0lUl0Ul_lllUUllUlUUUl0UU0UU0l0-00l0U0U0-0UlUllUl_UUUll00l0UlUllU0UUUUllUllUUlllUllllUU0llUlUllUUlll", - "microsoft.com": "llUllllUllllll=0; UUUU=000000U000U000U0000U0000000U0000; U-UU-UUUUUUUU=lll=00000l0%2200000l0%22llllll000l0%2200000lll%22llllllllllll000%22lllllllllll%22llllllllllllllll%22llllllllllllllll%22llllllllllllllllllllll%22llllllllllllllllll%22lll-lll-lllll0l0ll%22llllllllllllll%22lllllllllllllllll&lll=00l0000l-lll0-000l-llll-00l0000000ll; U-UU-Ulll=0; lllll_UllUU=0000000000~ll=00~ll=00ll0lll0l00l000000l0ll000ll000l; lllll_UllUU=0000000000~ll=00~ll=00ll0lll0l00l000000l0ll000ll000l", - "play.google.com": "UUU=000=lUUlUlU0UlUlUl0UU0UUUlU0UUlllUllUUUllUUU-Ul00lUUlUU0lUU_lU_lUUUUlUUUUUllUUl-UUl0l0U_lUlUlU0U000llUU_llUlllUl-lUUllUlUlU0lUUlUU0lUllUUlUUlllUUUl0_lllUllUU-llU0ll0U0U0UlU0Ul", - "plus.google.com": "__Ulll-UUUU=0:ll0U0lUl0lUlUUUlUlUlUllUllUlUl:lllUU0llUl00UUU0", - "sites.google.com": "__Ulll-UUUU=0:lll0l00lll0lUllll-l0UU0UlUllll:l0UUUUU0UlUUllUl", - "support.google.com": "UUU=000=lUlU00UlllllUUl0llUUll0lll0llll0lUlUlUl-0llUUUlUlllUUllU_llU00llllllUUUllUlUUlUlUlUlUlUllU-U_ll-0lUUUUlUUll0Ul0ll0UUUU0UUUU0llU-UllUUUlUl0U0lUUl0UlUUllUl0lllllUllUllUlU0ll; UUU=000=lUlU00UlllllUUl0llUUll0lll0llll0lUlUlUl-0llUUUlUlllUUllU_llU00llllllUUUllUlUUlUlUlUlUlUllU-U_ll-0lUUUUlUUll0Ul0ll0UUUU0UUUU0llU-UllUUUlUl0U0lUUl0UlUUllUl0lllllUllUllUlU0ll", - "www.google.com": "0U_UUU=0000-00-00-00; UUU=000=UlU0UlUlU0-lllUUUUlUU0lUlUUUUUUUUUlll-00l-0U0UUlUlUllUUlUUUl0_UUlUU0lll0UlllllUUUlU0UlUl0U0UU_0l-lU0UUUllU_lUUUlUlU_lU0llU0UlUllllllUUUlUl0UUl0lUU0lUUlUllUUlUUllUllUllUUUU", - "youtu.be": "UUU=0; UUU=UUU000lU0UU; UUUUUUU_UUUU0_UUUU=UUlUU0UUU0l", - "youtube.com": "UUU=0; UUU=0l00U0lUUlU; UUUUUUU_UUUU0_UUUU=lUlUllUUUlU" + "linkedin.com": "UUUUUUUUUU=llll:0000000000000000000; llll=l=0&llll=ll-ll; lllllll=\"l=0&ll000l0l-0lll-00l0-0000-0lll0ll0ll00\"; llllllll=\"l=0&0000000000000000l0l000-0l0l-0000-0000-0l0l00l0000lUUUUUl_llU0UlUllUUlU0lUlUl00llUl\"; llll=\"l=UUUU00:l=U:l=U:l=U:l=U:l=0000:l=0:l=0:l=0000000000:l=0000000000:l=0:lll=UUUUUlUlUUUUUUllllllU0UUlUlU0lll\"", + "maps.google.com": "0U_UUU=0000-00-00-00; UUU=000=UllUl00U-UU0llllUU0lUUlUl0llUl0U0lllUlUUU0l00UUUllllUlU0l0UllUUlUlU0UllUllU0UUlU00llUUUllUUlUl00lUlUUUlUUU0Ul00lllUUUUllUUl0UUlU0UllUlUUllllUllUllUll0llllllllll0lUUUlU0Ull", + "microsoft.com": "llUllllUllllll=0; UUUU=0UUU00U0000000U0000U000000UU00UU; U-UU-UUUUUUUU=lll=00000l0%2200000l%22llllll000l0%22llllllllllll000%22lllllllllll%22llllllllllllllll%22llllllllllllllll%22llllllllllllllllllllll%22llllllllllllllllll%22lll-lll-lllll0l0ll%22llllllllllll%22lllllllllllllllll%2200000l0ll&lll=0ll00ll0-000l-000l-l000-l00ll0l0l00l; U-UU-Ulll=0; lllll_UllUU=0000000000~ll=00~ll=0lll000ll0l0000lll000lll0ll0000l; lllll_UllUU=0000000000~ll=00~ll=0lll000ll0l0000lll000lll0ll0000l", + "play.google.com": "UUU=000=Ull0l00UlllUUUlU0UllUl0llU0l-lllUllUl0lllUU0UUU0lUlU-UUll000lUl00U0Ul_UlUU0l0lUUUUlUUl0UlUl0lU0-lll0l0l0UlUllllU0U0UU0U00UllU0l0lU0lll_0lUUU0UllUUUUll0UlUl0l0UUUUU00UUllll", + "plus.google.com": "__Ulll-UUUU=0:0Ull0lUU0UUUlll0U-UllUUllllUlU:lll00_lllUUUUUUU", + "sites.google.com": "__Ulll-UUUU=0:_UU0lll0UUUUlUU0lUll0UUlllllUl:UUll0lllU0UUlll0", + "support.google.com": "UUU=000=llU0lUlllUUlllUUll0U0UUll0UUlUUlU-lUUllU0UllUlUUlUlU0UlUUU_U-UlUU0lUUlUllUlUlUUl00llllUl0lUUUU00Ul0UUlUll0UUUU_UUlUlllUllllU0U0lllllUlU000UllUl--UUU_ll_lllU0UllUUlllU00UlU; UUU=000=llU0lUlllUUlllUUll0U0UUll0UUlUUlU-lUUllU0UllUlUUlUlU0UlUUU_U-UlUU0lUUlUllUlUlUUl00llllUl0lUUUU00Ul0UUlUll0UUUU_UUlUlllUllllU0U0lllllUlU000UllUl--UUU_ll_lllU0UllUUlllU00UlU", + "www.google.com": "0U_UUU=0000-00-00-00; UUU=UUUU_UUUlUUUUlUll_lllll0U00UUl0lllUUUUlUU_0_llUl0l0UUlU0_lU; UUU=000=lll0lUlUlllUll00U_lUlUUUUlll0lUlUU0lllUlllUllUUUll0U_U0llUU0UlU0Ull0U_l-_UUl00lUllUl0UUllUlUll0UUllUUUlU0UUlUllUlUUUlUllU-lUUlll0UlU0lUllUUUUlUUUlUlUU0llll_lU0lUlllll_UlUl", + "youtu.be": "UUU=0; UUU=UUUUUUUllUU; UUUUUUU_UUUU0_UUUU=00UlUU-UUU0", + "youtube.com": "UUU=0; UUU=lU0lUUUlUll; UUUUUUU_UUUU0_UUUU=0UUUlUllU0l" } diff --git a/package.json b/package.json index 2837a4e..6aa290f 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "mocha": "9.2.2", "nyc": "15.1.0", "safe-buffer": "5.2.1", - "top-sites": "1.1.89" + "top-sites": "1.1.97" }, "files": [ "HISTORY.md", From 2d6eec4d42f364c8206801fc2d5caa3e36f1c9f0 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 11 Apr 2022 19:16:03 -0400 Subject: [PATCH 108/159] docs: add security policy --- SECURITY.md | 25 +++++++++++++++++++++++++ package.json | 1 + 2 files changed, 26 insertions(+) create mode 100644 SECURITY.md diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 0000000..fd4a6c5 --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,25 @@ +# Security Policies and Procedures + +## Reporting a Bug + +The `cookie` team and community take all security bugs seriously. Thank +you for improving the security of the project. We appreciate your efforts and +responsible disclosure and will make every effort to acknowledge your +contributions. + +Report security bugs by emailing the current owner(s) of `cookie`. This +information can be found in the npm registry using the command +`npm owner ls cookie`. +If unsure or unable to get the information from the above, open an issue +in the [project issue tracker](https://github.com/jshttp/cookie/issues) +asking for the current contact information. + +To ensure the timely response to your report, please ensure that the entirety +of the report is contained within the email body and not solely behind a web +link or an attachment. + +At least one owner will acknowledge your email within 48 hours, and will send a +more detailed response within 48 hours indicating the next steps in handling +your report. After the initial reply to your report, the owners will +endeavor to keep you informed of the progress towards a fix and full +announcement, and may ask for additional information or guidance. diff --git a/package.json b/package.json index 6aa290f..7dab223 100644 --- a/package.json +++ b/package.json @@ -26,6 +26,7 @@ "HISTORY.md", "LICENSE", "README.md", + "SECURITY.md", "index.js" ], "engines": { From 663c9aeb85c9e046ff2ad2cdec631afdd40a7965 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 11 Apr 2022 19:30:47 -0400 Subject: [PATCH 109/159] 0.5.0 --- HISTORY.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index 5768609..ae9b995 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,5 +1,5 @@ -unreleased -========== +0.5.0 / 2022-04-11 +================== * Add `priority` option * Fix `expires` option to reject invalid dates diff --git a/package.json b/package.json index 7dab223..ed5606a 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "cookie", "description": "HTTP server cookie parsing and serialization", - "version": "0.4.2", + "version": "0.5.0", "author": "Roman Shtylman ", "contributors": [ "Douglas Christopher Wilson " From 1e849a8cf8eaaf5e428548b13e54d467cae9a5f8 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 4 Jul 2022 12:16:57 -0400 Subject: [PATCH 110/159] build: ubuntu@20.04 --- .github/workflows/ci.yml | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 95edacd..e7e788f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,7 +6,7 @@ on: jobs: test: - runs-on: ubuntu-18.04 + runs-on: ubuntu-20.04 strategy: matrix: name: @@ -90,12 +90,12 @@ jobs: - name: Node.js 8.x node-version: "8.17" - npm-i: mocha@7.1.2 + npm-i: mocha@7.1.2 nyc@14.1.1 npm-rm: beautify-benchmark benchmark top-sites - name: Node.js 9.x node-version: "9.11" - npm-i: mocha@7.1.2 + npm-i: mocha@7.1.2 nyc@14.1.1 npm-rm: beautify-benchmark benchmark top-sites - name: Node.js 10.x @@ -131,7 +131,10 @@ jobs: shell: bash -eo pipefail -l {0} run: | if [[ "${{ matrix.node-version }}" == 0.6* ]]; then - sudo apt-get install g++-4.8 gcc-4.8 libssl1.0-dev + sudo sh -c 'echo "deb http://us.archive.ubuntu.com/ubuntu/ bionic universe" >> /etc/apt/sources.list' + sudo sh -c 'echo "deb http://security.ubuntu.com/ubuntu bionic-security main" >> /etc/apt/sources.list' + sudo apt-get update + sudo apt-get install g++-4.8 gcc-4.8 libssl1.0-dev python2 python-is-python2 export CC=/usr/bin/gcc-4.8 export CXX=/usr/bin/g++-4.8 fi From a220f0cd83a10adf37af2d33ba96dfa1a3cc54c9 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 4 Jul 2022 12:32:24 -0400 Subject: [PATCH 111/159] build: mocha@10.0.0 --- .github/workflows/ci.yml | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e7e788f..d977391 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -108,9 +108,11 @@ jobs: - name: Node.js 12.x node-version: "12.22" + npm-i: mocha@9.2.2 - name: Node.js 13.x node-version: "13.14" + npm-i: mocha@9.2.2 - name: Node.js 14.x node-version: "14.19" diff --git a/package.json b/package.json index ed5606a..ee12f87 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "benchmark": "2.1.4", "eslint": "7.32.0", "eslint-plugin-markdown": "2.2.1", - "mocha": "9.2.2", + "mocha": "10.0.0", "nyc": "15.1.0", "safe-buffer": "5.2.1", "top-sites": "1.1.97" From 13848e9745a03d2698e423ea14110777425d7f1f Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 7 Jul 2022 22:41:10 -0400 Subject: [PATCH 112/159] build: support Node.js 18.x --- .github/workflows/ci.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d977391..da03057 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -31,6 +31,7 @@ jobs: - Node.js 15.x - Node.js 16.x - Node.js 17.x + - Node.js 18.x include: - name: Node.js 0.6 @@ -126,6 +127,9 @@ jobs: - name: Node.js 17.x node-version: "17.9" + - name: Node.js 18.x + node-version: "18.5" + steps: - uses: actions/checkout@v2 From 46d144d2f90ab4456ed25f176081e9ce6c4da094 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 7 Jul 2022 22:45:30 -0400 Subject: [PATCH 113/159] build: Node.js@14.20 --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index da03057..c0f4bc5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -116,7 +116,7 @@ jobs: npm-i: mocha@9.2.2 - name: Node.js 14.x - node-version: "14.19" + node-version: "14.20" - name: Node.js 15.x node-version: "15.14" From e443a2b66eb815f23fe966f02ccc3b02516823ea Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 7 Jul 2022 22:49:07 -0400 Subject: [PATCH 114/159] build: Node.js@16.16 --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c0f4bc5..c6a02d3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -122,7 +122,7 @@ jobs: node-version: "15.14" - name: Node.js 16.x - node-version: "16.14" + node-version: "16.16" - name: Node.js 17.x node-version: "17.9" From 893d7b50e04601a56abd42c21b3065e69cc6ed73 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Fri, 8 Jul 2022 00:17:14 -0400 Subject: [PATCH 115/159] build: eslint@8.19.0 --- .github/workflows/ci.yml | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c6a02d3..372e275 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -173,8 +173,8 @@ jobs: shell: bash run: | # eslint for linting - # - remove on Node.js < 10 - if [[ "$(cut -d. -f1 <<< "${{ matrix.node-version }}")" -lt 10 ]]; then + # - remove on Node.js < 12 + if [[ "$(cut -d. -f1 <<< "${{ matrix.node-version }}")" -lt 12 ]]; then node -pe 'Object.keys(require("./package").devDependencies).join("\n")' | \ grep -E '^eslint(-|$)' | \ sort -r | \ diff --git a/package.json b/package.json index ee12f87..f34155f 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "devDependencies": { "beautify-benchmark": "0.2.4", "benchmark": "2.1.4", - "eslint": "7.32.0", + "eslint": "8.19.0", "eslint-plugin-markdown": "2.2.1", "mocha": "10.0.0", "nyc": "15.1.0", From a0c84147aab6266bdb3996cf4062e93907c0b0fc Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 27 Jul 2022 22:41:13 -0400 Subject: [PATCH 116/159] build: eslint-plugin-markdown@3.0.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f34155f..9d69c8c 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "beautify-benchmark": "0.2.4", "benchmark": "2.1.4", "eslint": "8.19.0", - "eslint-plugin-markdown": "2.2.1", + "eslint-plugin-markdown": "3.0.0", "mocha": "10.0.0", "nyc": "15.1.0", "safe-buffer": "5.2.1", From a5d2984c7331d0d4bc0031ffa88a87082e0d628b Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 14 Sep 2022 23:18:24 -0400 Subject: [PATCH 117/159] build: Node.js@18.9 --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 372e275..fdba559 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -128,7 +128,7 @@ jobs: node-version: "17.9" - name: Node.js 18.x - node-version: "18.5" + node-version: "18.9" steps: - uses: actions/checkout@v2 From 29430720e79fc226364fbeca3d042e4de4b1640c Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 14 Sep 2022 23:20:50 -0400 Subject: [PATCH 118/159] build: Node.js@16.17 --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fdba559..54b91d5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -122,7 +122,7 @@ jobs: node-version: "15.14" - name: Node.js 16.x - node-version: "16.16" + node-version: "16.17" - name: Node.js 17.x node-version: "17.9" From c34a3eec322e7ee69d048e50e589fa809af29af7 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 14 Sep 2022 23:27:11 -0400 Subject: [PATCH 119/159] build: eslint@8.23.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9d69c8c..060f657 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "devDependencies": { "beautify-benchmark": "0.2.4", "benchmark": "2.1.4", - "eslint": "8.19.0", + "eslint": "8.23.1", "eslint-plugin-markdown": "3.0.0", "mocha": "10.0.0", "nyc": "15.1.0", From fa7a4b8b6f95e82fdfc8c3046b9aa19e54a8d7b2 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 8 Dec 2022 19:43:21 -0500 Subject: [PATCH 120/159] build: support Node.js 19.x --- .github/workflows/ci.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 54b91d5..20b95ea 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,6 +32,7 @@ jobs: - Node.js 16.x - Node.js 17.x - Node.js 18.x + - Node.js 19.x include: - name: Node.js 0.6 @@ -130,6 +131,9 @@ jobs: - name: Node.js 18.x node-version: "18.9" + - name: Node.js 19.x + node-version: "19.2" + steps: - uses: actions/checkout@v2 From 7c43f2812082f49ba896658dbeb1179e4e15992d Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 8 Dec 2022 19:48:01 -0500 Subject: [PATCH 121/159] build: Node.js@14.21 --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 20b95ea..340640d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -117,7 +117,7 @@ jobs: npm-i: mocha@9.2.2 - name: Node.js 14.x - node-version: "14.20" + node-version: "14.21" - name: Node.js 15.x node-version: "15.14" From 3cfb377540b13351d890d31534fcdc1e3cc191ea Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 8 Dec 2022 19:49:42 -0500 Subject: [PATCH 122/159] build: Node.js@16.19 --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 340640d..798c0ee 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -123,7 +123,7 @@ jobs: node-version: "15.14" - name: Node.js 16.x - node-version: "16.17" + node-version: "16.19" - name: Node.js 17.x node-version: "17.9" From b6b3d72945f28499d231406f8068fd12b1c87d8f Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 8 Dec 2022 19:51:27 -0500 Subject: [PATCH 123/159] build: Node.js@18.12 --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 798c0ee..07da557 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -129,7 +129,7 @@ jobs: node-version: "17.9" - name: Node.js 18.x - node-version: "18.9" + node-version: "18.12" - name: Node.js 19.x node-version: "19.2" From c802ea81911989541cb7718879fb273a821cbf08 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Fri, 9 Dec 2022 00:02:46 -0500 Subject: [PATCH 124/159] build: mocha@10.1.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 060f657..cf14469 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "benchmark": "2.1.4", "eslint": "8.23.1", "eslint-plugin-markdown": "3.0.0", - "mocha": "10.0.0", + "mocha": "10.1.0", "nyc": "15.1.0", "safe-buffer": "5.2.1", "top-sites": "1.1.97" From 44c4d39dd7109fafb178b6d59bcc1e7918e1b0b3 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Fri, 9 Dec 2022 00:06:47 -0500 Subject: [PATCH 125/159] build: eslint@8.29.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index cf14469..893c6f4 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "devDependencies": { "beautify-benchmark": "0.2.4", "benchmark": "2.1.4", - "eslint": "8.23.1", + "eslint": "8.29.0", "eslint-plugin-markdown": "3.0.0", "mocha": "10.1.0", "nyc": "15.1.0", From a96b1038fb76fda03548cc8759b913ba44362c44 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 1 Mar 2023 20:43:54 -0500 Subject: [PATCH 126/159] build: actions/checkout@v3 --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 07da557..46137fb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -135,7 +135,7 @@ jobs: node-version: "19.2" steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Install Node.js ${{ matrix.node-version }} shell: bash -eo pipefail -l {0} From a98d4f2f3a68d16eadcea0bfa99087e9e9295db7 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 1 Mar 2023 20:47:09 -0500 Subject: [PATCH 127/159] build: use $GITHUB_OUTPUT for environment list --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 46137fb..ec0862f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -195,7 +195,7 @@ jobs: echo "node@$(node -v)" echo "npm@$(npm -v)" npm -s ls ||: - (npm -s ls --depth=0 ||:) | awk -F'[ @]' 'NR>1 && $2 { print "::set-output name=" $2 "::" $3 }' + (npm -s ls --depth=0 ||:) | awk -F'[ @]' 'NR>1 && $2 { print $2 "=" $3 }' >> "$GITHUB_OUTPUT" - name: Run tests shell: bash From dd6f061fd49ae278d05a63c2eb8db154e1b9975a Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 30 Oct 2023 21:27:20 -0400 Subject: [PATCH 128/159] build: support Node.js 20.x --- .github/workflows/ci.yml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ec0862f..0d5254d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -33,6 +33,7 @@ jobs: - Node.js 17.x - Node.js 18.x - Node.js 19.x + - Node.js 20.x include: - name: Node.js 0.6 @@ -134,6 +135,9 @@ jobs: - name: Node.js 19.x node-version: "19.2" + - name: Node.js 20.x + node-version: "20.9" + steps: - uses: actions/checkout@v3 @@ -163,7 +167,12 @@ jobs: dirname "$(nvm which ${{ matrix.node-version }})" >> "$GITHUB_PATH" - name: Configure npm - run: npm config set shrinkwrap false + run: | + if [[ "$(npm config get package-lock)" == "true" ]]; then + npm config set package-lock false + else + npm config set shrinkwrap false + fi - name: Remove npm module(s) ${{ matrix.npm-rm }} run: npm rm --silent --save-dev ${{ matrix.npm-rm }} From 9669cfa7370485cde866f27cadcc976bbfacfe6f Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 30 Oct 2023 21:30:31 -0400 Subject: [PATCH 129/159] build: support Node.js 21.x --- .github/workflows/ci.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0d5254d..94521b7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -34,6 +34,7 @@ jobs: - Node.js 18.x - Node.js 19.x - Node.js 20.x + - Node.js 21.x include: - name: Node.js 0.6 @@ -138,6 +139,9 @@ jobs: - name: Node.js 20.x node-version: "20.9" + - name: Node.js 21.x + node-version: "21.1" + steps: - uses: actions/checkout@v3 From 10ca9aec53808e36553fc3b01960535641cbb437 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 30 Oct 2023 21:32:21 -0400 Subject: [PATCH 130/159] build: Node.js@18.18 --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 94521b7..423195b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -131,7 +131,7 @@ jobs: node-version: "17.9" - name: Node.js 18.x - node-version: "18.12" + node-version: "18.18" - name: Node.js 19.x node-version: "19.2" From b3f5e76f36c66a92cc983555d3270b46cb46354b Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 30 Oct 2023 21:34:43 -0400 Subject: [PATCH 131/159] build: Node.js@19.9 --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 423195b..7a2590e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -134,7 +134,7 @@ jobs: node-version: "18.18" - name: Node.js 19.x - node-version: "19.2" + node-version: "19.9" - name: Node.js 20.x node-version: "20.9" From 6e765ee3992641d5dfe3998375da6783695cba2a Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 30 Oct 2023 21:36:10 -0400 Subject: [PATCH 132/159] build: Node.js@16.20 --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7a2590e..3469d1e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -125,7 +125,7 @@ jobs: node-version: "15.14" - name: Node.js 16.x - node-version: "16.19" + node-version: "16.20" - name: Node.js 17.x node-version: "17.9" From 197f670665f974e4bd8683472beb2be7e9d84d34 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sun, 5 Nov 2023 21:45:24 -0500 Subject: [PATCH 133/159] build: eslint@8.53.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 893c6f4..922bf37 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "devDependencies": { "beautify-benchmark": "0.2.4", "benchmark": "2.1.4", - "eslint": "8.29.0", + "eslint": "8.53.0", "eslint-plugin-markdown": "3.0.0", "mocha": "10.1.0", "nyc": "15.1.0", From 936036a35d231aef447cd5745995e6fb777e3277 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sun, 5 Nov 2023 21:47:50 -0500 Subject: [PATCH 134/159] build: eslint-plugin-markdown@3.0.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 922bf37..73d2425 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "beautify-benchmark": "0.2.4", "benchmark": "2.1.4", "eslint": "8.53.0", - "eslint-plugin-markdown": "3.0.0", + "eslint-plugin-markdown": "3.0.1", "mocha": "10.1.0", "nyc": "15.1.0", "safe-buffer": "5.2.1", From da7e44e000c830ca5cc4f3c54c49e83bddb7f11b Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Sun, 5 Nov 2023 21:49:12 -0500 Subject: [PATCH 135/159] build: mocha@10.2.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 73d2425..da61c8c 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "benchmark": "2.1.4", "eslint": "8.53.0", "eslint-plugin-markdown": "3.0.1", - "mocha": "10.1.0", + "mocha": "10.2.0", "nyc": "15.1.0", "safe-buffer": "5.2.1", "top-sites": "1.1.97" From 5f22857c6e6b9784f7e1be0ee1b4fc13243098c4 Mon Sep 17 00:00:00 2001 From: Rakesh Bisht Date: Thu, 2 Mar 2023 14:57:08 +0530 Subject: [PATCH 136/159] Fix typo in JSDoc closes #150 --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 9c3d07d..12128b9 100644 --- a/index.js +++ b/index.js @@ -233,7 +233,7 @@ function decode (str) { /** * URL-encode value. * - * @param {string} str + * @param {string} val * @returns {string} */ From 52a76c1ff37e640b5eb4a5dd7fa87f395711626d Mon Sep 17 00:00:00 2001 From: Rakesh Bisht Date: Thu, 2 Mar 2023 14:44:19 +0530 Subject: [PATCH 137/159] docs: fix typo in HISTORY closes #149 --- HISTORY.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/HISTORY.md b/HISTORY.md index ae9b995..4ca50a1 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -41,7 +41,7 @@ * perf: enable strict mode * perf: use for loop in parse - * perf: use string concatination for serialization + * perf: use string concatenation for serialization 0.2.3 / 2015-10-25 ================== From c67a478f92541cca8bc25ec56eef880af5b0062e Mon Sep 17 00:00:00 2001 From: Afanasii Kurakin Date: Mon, 18 Apr 2022 22:54:24 +0300 Subject: [PATCH 138/159] docs: fix typos in HISTORY closes #140 --- HISTORY.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index 4ca50a1..1748679 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -3,14 +3,14 @@ * Add `priority` option * Fix `expires` option to reject invalid dates - * pref: improve default decode speed - * pref: remove slow string split in parse + * perf: improve default decode speed + * perf: remove slow string split in parse 0.4.2 / 2022-02-02 ================== - * pref: read value only when assigning in parse - * pref: remove unnecessary regexp in parse + * perf: read value only when assigning in parse + * perf: remove unnecessary regexp in parse 0.4.1 / 2020-04-21 ================== From 84a156749b673dbfbf43679829b15be09fbd8988 Mon Sep 17 00:00:00 2001 From: pazguille Date: Wed, 30 Aug 2023 20:54:56 -0300 Subject: [PATCH 139/159] Add partitioned option closes #147 closes #151 closes #153 --- HISTORY.md | 5 +++++ README.md | 12 ++++++++++++ index.js | 4 ++++ test/serialize.js | 14 ++++++++++++++ 4 files changed, 35 insertions(+) diff --git a/HISTORY.md b/HISTORY.md index 1748679..b7271e4 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,3 +1,8 @@ +unreleased +========== + + * Add `partitioned` option + 0.5.0 / 2022-04-11 ================== diff --git a/README.md b/README.md index 5449c3a..9b98434 100644 --- a/README.md +++ b/README.md @@ -107,6 +107,17 @@ The given number will be converted to an integer by rounding down. By default, n `maxAge` are set, then `maxAge` takes precedence, but it is possible not all clients by obey this, so if both are set, they should point to the same date and time. +##### partitioned + +Specifies the `boolean` value for the [`Partitioned` `Set-Cookie`](rfc-cutler-httpbis-partitioned-cookies) +attribute. When truthy, the `Partitioned` attribute is set, otherwise it is not. By default, the +`Partitioned` attribute is not set. + +**note** This is an attribute that has not yet been fully standardized, and may change in the future. +This also means many clients may ignore this attribute until they understand it. + +More information about can be found in [the proposal](https://github.com/privacycg/CHIPS). + ##### path Specifies the value for the [`Path` `Set-Cookie` attribute][rfc-6265-5.2.4]. By default, the path @@ -275,6 +286,7 @@ $ npm run bench - [RFC 6265: HTTP State Management Mechanism][rfc-6265] - [Same-site Cookies][rfc-6265bis-09-5.4.7] +[rfc-cutler-httpbis-partitioned-cookies]: https://tools.ietf.org/html/draft-cutler-httpbis-partitioned-cookies/ [rfc-west-cookie-priority-00-4.1]: https://tools.ietf.org/html/draft-west-cookie-priority-00#section-4.1 [rfc-6265bis-09-5.4.7]: https://tools.ietf.org/html/draft-ietf-httpbis-rfc6265bis-09#section-5.4.7 [rfc-6265]: https://tools.ietf.org/html/rfc6265 diff --git a/index.js b/index.js index 12128b9..03d4c38 100644 --- a/index.js +++ b/index.js @@ -172,6 +172,10 @@ function serialize(name, val, options) { str += '; Secure'; } + if (opt.partitioned) { + str += '; Partitioned' + } + if (opt.priority) { var priority = typeof opt.priority === 'string' ? opt.priority.toLowerCase() diff --git a/test/serialize.js b/test/serialize.js index 6e34590..80d0c48 100644 --- a/test/serialize.js +++ b/test/serialize.js @@ -113,6 +113,20 @@ describe('cookie.serialize(name, value, options)', function () { }) }) + describe('with "partitioned" option', function () { + it('should include partitioned flag when true', function () { + assert.equal(cookie.serialize('foo', 'bar', { partitioned: true }), 'foo=bar; Partitioned') + }) + + it('should not include partitioned flag when false', function () { + assert.equal(cookie.serialize('foo', 'bar', { partitioned: false }), 'foo=bar') + }) + + it('should not include partitioned flag when not defined', function () { + assert.equal(cookie.serialize('foo', 'bar', {}), 'foo=bar') + }) + }) + describe('with "path" option', function () { it('should serialize path', function () { assert.equal(cookie.serialize('foo', 'bar', { path: '/' }), 'foo=bar; Path=/') From c45b52d9bd5da38127123195937d48385dd51908 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 6 Nov 2023 21:01:55 -0500 Subject: [PATCH 140/159] docs: switch badges to badgen --- README.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 9b98434..d17cb76 100644 --- a/README.md +++ b/README.md @@ -2,9 +2,9 @@ [![NPM Version][npm-version-image]][npm-url] [![NPM Downloads][npm-downloads-image]][npm-url] -[![Node.js Version][node-version-image]][node-version-url] -[![Build Status][github-actions-ci-image]][github-actions-ci-url] -[![Test Coverage][coveralls-image]][coveralls-url] +[![Node.js Version][node-image]][node-url] +[![Build Status][ci-image]][ci-url] +[![Coverage Status][coveralls-image]][coveralls-url] Basic HTTP cookie parser and serializer for HTTP servers. @@ -303,12 +303,12 @@ $ npm run bench [MIT](LICENSE) +[ci-image]: https://badgen.net/github/checks/jshttp/cookie/master?label=ci +[ci-url]: https://github.com/jshttp/cookie/actions/workflows/ci.yml [coveralls-image]: https://badgen.net/coveralls/c/github/jshttp/cookie/master [coveralls-url]: https://coveralls.io/r/jshttp/cookie?branch=master -[github-actions-ci-image]: https://img.shields.io/github/workflow/status/jshttp/cookie/ci/master?label=ci -[github-actions-ci-url]: https://github.com/jshttp/cookie/actions/workflows/ci.yml -[node-version-image]: https://badgen.net/npm/node/cookie -[node-version-url]: https://nodejs.org/en/download +[node-image]: https://badgen.net/npm/node/cookie +[node-url]: https://nodejs.org/en/download [npm-downloads-image]: https://badgen.net/npm/dm/cookie [npm-url]: https://npmjs.org/package/cookie [npm-version-image]: https://badgen.net/npm/v/cookie From 7560154fea525e56c1e7c736039b5cc69550fb32 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 6 Nov 2023 23:58:43 -0500 Subject: [PATCH 141/159] build: top-sites@1.1.194 --- README.md | 85 +++++++++++++++++++++------------------- benchmark/parse-top.json | 28 ++++++------- package.json | 2 +- 3 files changed, 58 insertions(+), 57 deletions(-) diff --git a/README.md b/README.md index d17cb76..71fdac1 100644 --- a/README.md +++ b/README.md @@ -223,49 +223,52 @@ $ npm test ``` $ npm run bench -> cookie@0.4.2 bench +> cookie@0.5.0 bench > node benchmark/index.js - node@16.14.0 - v8@9.4.146.24-node.20 - uv@1.43.0 - zlib@1.2.11 + node@18.18.2 + acorn@8.10.0 + ada@2.6.0 + ares@1.19.1 brotli@1.0.9 - ares@1.18.1 - modules@93 - nghttp2@1.45.1 - napi@8 - llhttp@6.0.4 - openssl@1.1.1m+quic - cldr@40.0 - icu@70.1 - tz@2021a3 - unicode@14.0 - ngtcp2@0.1.0-DEV - nghttp3@0.1.0-DEV + cldr@43.1 + icu@73.2 + llhttp@6.0.11 + modules@108 + napi@9 + nghttp2@1.57.0 + nghttp3@0.7.0 + ngtcp2@0.8.1 + openssl@3.0.10+quic + simdutf@3.2.14 + tz@2023c + undici@5.26.3 + unicode@15.0 + uv@1.44.2 + uvwasi@0.0.18 + v8@10.2.154.26-node.26 + zlib@1.2.13.1-motley > node benchmark/parse-top.js cookie.parse - top sites - 15 tests completed. - - parse accounts.google.com x 2,421,245 ops/sec ±0.80% (188 runs sampled) - parse apple.com x 2,684,710 ops/sec ±0.59% (189 runs sampled) - parse cloudflare.com x 2,231,418 ops/sec ±0.76% (186 runs sampled) - parse docs.google.com x 2,316,357 ops/sec ±1.28% (187 runs sampled) - parse drive.google.com x 2,363,543 ops/sec ±0.49% (189 runs sampled) - parse en.wikipedia.org x 839,414 ops/sec ±0.53% (189 runs sampled) - parse linkedin.com x 553,797 ops/sec ±0.63% (190 runs sampled) - parse maps.google.com x 1,314,779 ops/sec ±0.72% (189 runs sampled) - parse microsoft.com x 153,783 ops/sec ±0.53% (190 runs sampled) - parse play.google.com x 2,249,574 ops/sec ±0.59% (187 runs sampled) - parse plus.google.com x 2,258,682 ops/sec ±0.60% (188 runs sampled) - parse sites.google.com x 2,247,069 ops/sec ±0.68% (189 runs sampled) - parse support.google.com x 1,456,840 ops/sec ±0.70% (187 runs sampled) - parse www.google.com x 1,046,028 ops/sec ±0.58% (188 runs sampled) - parse youtu.be x 937,428 ops/sec ±1.47% (190 runs sampled) - parse youtube.com x 963,878 ops/sec ±0.59% (190 runs sampled) + 14 tests completed. + + parse accounts.google.com x 2,588,913 ops/sec ±0.74% (186 runs sampled) + parse apple.com x 2,370,002 ops/sec ±0.69% (186 runs sampled) + parse cloudflare.com x 2,213,102 ops/sec ±0.88% (188 runs sampled) + parse docs.google.com x 2,194,157 ops/sec ±1.03% (184 runs sampled) + parse drive.google.com x 2,265,084 ops/sec ±0.79% (187 runs sampled) + parse en.wikipedia.org x 457,099 ops/sec ±0.81% (186 runs sampled) + parse linkedin.com x 504,407 ops/sec ±0.89% (186 runs sampled) + parse maps.google.com x 1,230,959 ops/sec ±0.98% (186 runs sampled) + parse microsoft.com x 926,294 ops/sec ±0.88% (184 runs sampled) + parse play.google.com x 2,311,338 ops/sec ±0.83% (185 runs sampled) + parse support.google.com x 1,508,850 ops/sec ±0.86% (186 runs sampled) + parse www.google.com x 1,022,582 ops/sec ±1.32% (182 runs sampled) + parse youtu.be x 332,136 ops/sec ±1.02% (185 runs sampled) + parse youtube.com x 323,833 ops/sec ±0.77% (183 runs sampled) > node benchmark/parse.js @@ -273,12 +276,12 @@ $ npm run bench 6 tests completed. - simple x 2,745,604 ops/sec ±0.77% (185 runs sampled) - decode x 557,287 ops/sec ±0.60% (188 runs sampled) - unquote x 2,498,475 ops/sec ±0.55% (189 runs sampled) - duplicates x 868,591 ops/sec ±0.89% (187 runs sampled) - 10 cookies x 306,745 ops/sec ±0.49% (190 runs sampled) - 100 cookies x 22,414 ops/sec ±2.38% (182 runs sampled) + simple x 3,214,032 ops/sec ±1.61% (183 runs sampled) + decode x 587,237 ops/sec ±1.16% (187 runs sampled) + unquote x 2,954,618 ops/sec ±1.35% (183 runs sampled) + duplicates x 857,008 ops/sec ±0.89% (187 runs sampled) + 10 cookies x 292,133 ops/sec ±0.89% (187 runs sampled) + 100 cookies x 22,610 ops/sec ±0.68% (187 runs sampled) ``` ## References diff --git a/benchmark/parse-top.json b/benchmark/parse-top.json index 37f8677..0530aa9 100644 --- a/benchmark/parse-top.json +++ b/benchmark/parse-top.json @@ -1,18 +1,16 @@ { - "accounts.google.com": "__Ulll-UUUU=0:0U0lUlllUUUl0lUl00UUUUUU0lUlll:l0ll0UlUU0l0lUUU", + "accounts.google.com": "__Ulll-UUUU=0:lllllUlUUUlUU_llUU0UUUl0lU0UUl:UUlUlUl0UU0UlUlU", "apple.com": "lll=UU", - "cloudflare.com": "__ll_ll=lUllUll.0Ul0Ull0UUUU.ll_U0lllUU0UlUll0lUllU-0000000000-0-UUUl+0Ulll0UUUU0U0Ullll0UUUUUlllU0UUUUlUUUlUUUUUUUlUlUUll0l0UlUlUl0Ul000UUlUU0/0l0l0UU0UllUU0U0lU/lllU0lUllU", - "docs.google.com": "__Ulll-UUUU=0:Ulll0UlUUllUlUl0UUlUUlUU0UUUUU:U0U0U0llUU0-0Ul0", - "drive.google.com": "__Ulll-UUUU=0:UUll0UllUUll0lUU0llUUllUllUlll:U0UllUlll-lU0lll", - "en.wikipedia.org": "UUU-Ulll-Ulllll=00-Ull-0000; UUU-Ulll-Ulllll-Ulllll=00-Ull-0000; UllUU=UU:UU:Ulllllllllll:00.00:-00.00:l0", - "linkedin.com": "UUUUUUUUUU=llll:0000000000000000000; llll=l=0&llll=ll-ll; lllllll=\"l=0&ll000l0l-0lll-00l0-0000-0lll0ll0ll00\"; llllllll=\"l=0&0000000000000000l0l000-0l0l-0000-0000-0l0l00l0000lUUUUUl_llU0UlUllUUlU0lUlUl00llUl\"; llll=\"l=UUUU00:l=U:l=U:l=U:l=U:l=0000:l=0:l=0:l=0000000000:l=0000000000:l=0:lll=UUUUUlUlUUUUUUllllllU0UUlUlU0lll\"", - "maps.google.com": "0U_UUU=0000-00-00-00; UUU=000=UllUl00U-UU0llllUU0lUUlUl0llUl0U0lllUlUUU0l00UUUllllUlU0l0UllUUlUlU0UllUllU0UUlU00llUUUllUUlUl00lUlUUUlUUU0Ul00lllUUUUllUUl0UUlU0UllUlUUllllUllUllUll0llllllllll0lUUUlU0Ull", - "microsoft.com": "llUllllUllllll=0; UUUU=0UUU00U0000000U0000U000000UU00UU; U-UU-UUUUUUUU=lll=00000l0%2200000l%22llllll000l0%22llllllllllll000%22lllllllllll%22llllllllllllllll%22llllllllllllllll%22llllllllllllllllllllll%22llllllllllllllllll%22lll-lll-lllll0l0ll%22llllllllllll%22lllllllllllllllll%2200000l0ll&lll=0ll00ll0-000l-000l-l000-l00ll0l0l00l; U-UU-Ulll=0; lllll_UllUU=0000000000~ll=00~ll=0lll000ll0l0000lll000lll0ll0000l; lllll_UllUU=0000000000~ll=00~ll=0lll000ll0l0000lll000lll0ll0000l", - "play.google.com": "UUU=000=Ull0l00UlllUUUlU0UllUl0llU0l-lllUllUl0lllUU0UUU0lUlU-UUll000lUl00U0Ul_UlUU0l0lUUUUlUUl0UlUl0lU0-lll0l0l0UlUllllU0U0UU0U00UllU0l0lU0lll_0lUUU0UllUUUUll0UlUl0l0UUUUU00UUllll", - "plus.google.com": "__Ulll-UUUU=0:0Ull0lUU0UUUlll0U-UllUUllllUlU:lll00_lllUUUUUUU", - "sites.google.com": "__Ulll-UUUU=0:_UU0lll0UUUUlUU0lUll0UUlllllUl:UUll0lllU0UUlll0", - "support.google.com": "UUU=000=llU0lUlllUUlllUUll0U0UUll0UUlUUlU-lUUllU0UllUlUUlUlU0UlUUU_U-UlUU0lUUlUllUlUlUUl00llllUl0lUUUU00Ul0UUlUll0UUUU_UUlUlllUllllU0U0lllllUlU000UllUl--UUU_ll_lllU0UllUUlllU00UlU; UUU=000=llU0lUlllUUlllUUll0U0UUll0UUlUUlU-lUUllU0UllUlUUlUlU0UlUUU_U-UlUU0lUUlUllUlUlUUl00llllUl0lUUUU00Ul0UUlUll0UUUU_UUlUlllUllllU0U0lllllUlU000UllUl--UUU_ll_lllU0UllUUlllU00UlU", - "www.google.com": "0U_UUU=0000-00-00-00; UUU=UUUU_UUUlUUUUlUll_lllll0U00UUl0lllUUUUlUU_0_llUl0l0UUlU0_lU; UUU=000=lll0lUlUlllUll00U_lUlUUUUlll0lUlUU0lllUlllUllUUUll0U_U0llUU0UlU0Ull0U_l-_UUl00lUllUl0UUllUlUll0UUllUUUlU0UUlUllUlUUUlUllU-lUUlll0UlU0lUllUUUUlUUUlUlUU0llll_lU0lUlllll_UlUl", - "youtu.be": "UUU=0; UUU=UUUUUUUllUU; UUUUUUU_UUUU0_UUUU=00UlUU-UUU0", - "youtube.com": "UUU=0; UUU=lU0lUUUlUll; UUUUUUU_UUUU0_UUUU=0UUUlUllU0l" + "cloudflare.com": "__ll_ll=llUUlU0U0UlUlUll.lllUUUUlUUUlUUlUU000UlllUl-0000000000-0-UllU00UUllllUUUllUl0l0llllUUlU0UlUUUlUUl0Ull/l0+lllllUlUlU0l0l00ll+0U0ll/l0UlU00lllllllUUll0lU00lUUUllUUlUUl", + "docs.google.com": "__Ulll-UUUU=0:lUlUlU0UUlUllUUlUllUUlUUlU0U:Ul0UllUUllll0UUl", + "drive.google.com": "__Ulll-UUUU=0:U0l0lUUllU0lllUlU0UU00UlllUUlU:lUUUllUlUUUllUUl", + "en.wikipedia.org": "UUU-Ulll-Ulllll=00-Ull-0000; UUU-Ulll-Ulllll-Ulllll=00-Ull-0000; UUU-UU=lll; UllUU=UU:UU:Ulllllllllll:00.00:-00.00:l0; UllllllUllllUllll=0.000", + "linkedin.com": "UUUUUUUUUU=llll:0000000000000000000; llll=l=0&llll=ll-ll; lllllll=\"l=0&0l0ll000-0000-00ll-0000-0l000ll00000\"; llllllll=\"l=0&00000000000000l00l0l0l-l000-00l0-00ll-l0000l000000UUUUlUlUU0llll0UlllUU0UU--UUlUlU\"; llll=\"l=UUUU00:l=U:l=U:l=U:l=U:l=0000:l=0:l=0:l=0000000000:l=0000000000:l=0:lll=UUU-UUlUlUUl0lUUlUlUllll0lllUUUU\"", + "maps.google.com": "0U_UUU=0000-00-00-00; UUU=000=lU00_U0UllU-lUlUUUllUl0l0U_lUlUUUl00UUU0llllU_UUlUUU0UllUllll0l-_lUlllUU0llll0UlUUllll_UU0U0lU-llUllll00lUllUllUlUlllU_lUUUl0ll0lUUlUlllUUl0llUUl0UU0llUlllllUllUll0UUUllUU", + "microsoft.com": "UUUUU=llllll0; lllll_UllUU=0000000000~ll=00~ll=0000l0l0l0lllll0l000000000l0l00l; lllll_UllUU=0000000000~ll=00~ll=0000l0l0l0lllll0l000000000l0l00l", + "play.google.com": "UUU=000=UllU0l0UU0llUlU0UUU0lUUUl0lUlUUllUlUl0ll0UlUlllUlUlUUlUUllUll-UUll0llll0UllUlUU0U0lUUUUU0Ull0l0l0l0lUU0UlUU000lUUUU0lU_UUlUUlUUl0UU-lUlUU0lUlUllUUUllUUllll00lllU0U0UUU0Ull", + "support.google.com": "UUU=000=l0llUUlUllU0UlllU0U0U0UlU-Ulll0lUlllU0UUllUUlUUUlllllUUUU-UUllUllU0lUU0U0U00lU0UUlUl0l0lUUlUUUUl0lUU0UUllUlUlUUlUlUUUU0ll0l0UU0lllU0lllUUUU0U0lU0U00l0Ul0UlU-U0UllU00lUUl0U; UUU=000=l0llUUlUllU0UlllU0U0U0UlU-Ulll0lUlllU0UUllUUlUUUlllllUUUU-UUllUllU0lUU0U0U00lU0UUlUl0l0lUUlUUUUl0lUU0UUllUlUlUUlUlUUUU0ll0l0UU0lllU0lllUUUU0U0lU0U00l0Ul0UlU-U0UllU00lUUl0U", + "www.google.com": "0U_UUU=0000-00-00-00; UUU=Ullll0Ullll0U0llUllU00U_lllll0lUUlUl0UllUlUUl0lUlUUUl00UUl; UUU=000=lUU0U0U0U0UllUUUlUUlUUU_UlUll_l0U0UU00lUlUlUlllllUUUl00UllllUU_0ll0UllUllUUU-UUUlllU0UlUlUllUlUllUll00UllU0U00llUUl0lU00lUlUUlllUl_U00UUlU0UU0UllUlUU0lUUlUUUl00lUUlUUUU0ll", + "youtu.be": "UUU=0; UUU=ll0UU-l0lUl; UUUUUUU_UUUU0_UUUU=0_llUUlUllU; UUUUUUU_UUUUUUU_UUUUUUUU=UlUUUlUUUlU%22", + "youtube.com": "UUU=0; UUU=l0_UlUUUlUl; UUUUUUU_UUUU0_UUUU=UUUUlUUUlll; UUUUUUU_UUUUUUU_UUUUUUUU=UlUUUlUUUlU%22" } diff --git a/package.json b/package.json index da61c8c..19edad1 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "mocha": "10.2.0", "nyc": "15.1.0", "safe-buffer": "5.2.1", - "top-sites": "1.1.97" + "top-sites": "1.1.194" }, "files": [ "HISTORY.md", From 38323bad3aa04bce840103ff6075bc05cc0bf884 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Mon, 6 Nov 2023 23:58:58 -0500 Subject: [PATCH 142/159] 0.6.0 --- HISTORY.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index b7271e4..41ae4b0 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,5 +1,5 @@ -unreleased -========== +0.6.0 / 2023-11-06 +================== * Add `partitioned` option diff --git a/package.json b/package.json index 19edad1..0c3f006 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "cookie", "description": "HTTP server cookie parsing and serialization", - "version": "0.5.0", + "version": "0.6.0", "author": "Roman Shtylman ", "contributors": [ "Douglas Christopher Wilson " From 2294a8f0cde395ad0912d053ae9a19c013120e23 Mon Sep 17 00:00:00 2001 From: Carlos Serrano Date: Mon, 29 Apr 2024 09:03:39 +0200 Subject: [PATCH 143/159] ci: add scorecard pipeline (#158) PR-URL: https://github.com/jshttp/cookie/pull/158 --- .github/workflows/scorecard.yml | 72 +++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 .github/workflows/scorecard.yml diff --git a/.github/workflows/scorecard.yml b/.github/workflows/scorecard.yml new file mode 100644 index 0000000..3bfd85a --- /dev/null +++ b/.github/workflows/scorecard.yml @@ -0,0 +1,72 @@ +# This workflow uses actions that are not certified by GitHub. They are provided +# by a third-party and are governed by separate terms of service, privacy +# policy, and support documentation. + +name: Scorecard supply-chain security +on: + # For Branch-Protection check. Only the default branch is supported. See + # https://github.com/ossf/scorecard/blob/main/docs/checks.md#branch-protection + branch_protection_rule: + # To guarantee Maintained check is occasionally updated. See + # https://github.com/ossf/scorecard/blob/main/docs/checks.md#maintained + schedule: + - cron: '16 21 * * 1' + push: + branches: [ "master" ] + +# Declare default permissions as read only. +permissions: read-all + +jobs: + analysis: + name: Scorecard analysis + runs-on: ubuntu-latest + permissions: + # Needed to upload the results to code-scanning dashboard. + security-events: write + # Needed to publish results and get a badge (see publish_results below). + id-token: write + # Uncomment the permissions below if installing in a private repository. + # contents: read + # actions: read + + steps: + - name: "Checkout code" + uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 + with: + persist-credentials: false + + - name: "Run analysis" + uses: ossf/scorecard-action@99c53751e09b9529366343771cc321ec74e9bd3d # v2.0.6 + with: + results_file: results.sarif + results_format: sarif + # (Optional) "write" PAT token. Uncomment the `repo_token` line below if: + # - you want to enable the Branch-Protection check on a *public* repository, or + # - you are installing Scorecard on a *private* repository + # To create the PAT, follow the steps in https://github.com/ossf/scorecard-action#authentication-with-pat. + # repo_token: ${{ secrets.SCORECARD_TOKEN }} + + # Public repositories: + # - Publish results to OpenSSF REST API for easy access by consumers + # - Allows the repository to include the Scorecard badge. + # - See https://github.com/ossf/scorecard-action#publishing-results. + # For private repositories: + # - `publish_results` will always be set to `false`, regardless + # of the value entered here. + publish_results: true + + # Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF + # format to the repository Actions tab. + - name: "Upload artifact" + uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3 + with: + name: SARIF file + path: results.sarif + retention-days: 5 + + # Upload the results to GitHub's code scanning dashboard. + - name: "Upload to code-scanning" + uses: github/codeql-action/upload-sarif@2f93e4319b2f04a2efc38fa7f78bd681bc3f7b2f # v2.23.2 + with: + sarif_file: results.sarif \ No newline at end of file From 26031e362d8473112b24a76c7c03b45ef7576d61 Mon Sep 17 00:00:00 2001 From: Nell Boulle Date: Mon, 29 Apr 2024 13:10:15 +0200 Subject: [PATCH 144/159] docs: fix typo in function description (#161) PR-URL: https://github.com/jshttp/cookie/pull/161 --- index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 03d4c38..7506a79 100644 --- a/index.js +++ b/index.js @@ -95,8 +95,8 @@ function parse(str, options) { /** * Serialize data into a cookie header. * - * Serialize the a name value pair into a cookie string suitable for - * http headers. An optional options object specified cookie parameters. + * Serialize a name value pair into a cookie string suitable for + * http headers. An optional options object specifies cookie parameters. * * serialize('foo', 'bar', { httpOnly: true }) * => "foo=bar; httpOnly" From e10042845354fea83bd8f34af72475eed1dadf5c Mon Sep 17 00:00:00 2001 From: Brian Ewins <119598239+bewinsnw@users.noreply.github.com> Date: Tue, 1 Oct 2024 23:56:55 +0100 Subject: [PATCH 145/159] fix: narrow the validation of cookies to match RFC6265 (#167) --- index.js | 64 ++++++++++++++++++++++++++++++++++++++++------- test/serialize.js | 4 +++ 2 files changed, 59 insertions(+), 9 deletions(-) diff --git a/index.js b/index.js index 7506a79..6fe633d 100644 --- a/index.js +++ b/index.js @@ -23,14 +23,60 @@ exports.serialize = serialize; var __toString = Object.prototype.toString /** - * RegExp to match field-content in RFC 7230 sec 3.2 + * RegExp to match cookie-name in RFC 6265 sec 4.1.1 + * This refers out to the obsoleted definition of token in RFC 2616 sec 2.2 + * which has been replaced by the token definition in RFC 7230 appendix B. * - * field-content = field-vchar [ 1*( SP / HTAB ) field-vchar ] - * field-vchar = VCHAR / obs-text - * obs-text = %x80-FF + * cookie-name = token + * token = 1*tchar + * tchar = "!" / "#" / "$" / "%" / "&" / "'" / + * "*" / "+" / "-" / "." / "^" / "_" / + * "`" / "|" / "~" / DIGIT / ALPHA */ -var fieldContentRegExp = /^[\u0009\u0020-\u007e\u0080-\u00ff]+$/; +var cookieNameRegExp = /^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/; + +/** + * RegExp to match cookie-value in RFC 6265 sec 4.1.1 + * + * cookie-value = *cookie-octet / ( DQUOTE *cookie-octet DQUOTE ) + * cookie-octet = %x21 / %x23-2B / %x2D-3A / %x3C-5B / %x5D-7E + * ; US-ASCII characters excluding CTLs, + * ; whitespace DQUOTE, comma, semicolon, + * ; and backslash + */ + +var cookieValueRegExp = /^("?)[\u0021\u0023-\u002B\u002D-\u003A\u003C-\u005B\u005D-\u007E]*\1$/; + +/** + * RegExp to match domain-value in RFC 6265 sec 4.1.1 + * + * domain-value = + * ; defined in [RFC1034], Section 3.5, as + * ; enhanced by [RFC1123], Section 2.1 + * =