Skip to content
This repository was archived by the owner on Sep 3, 2022. It is now read-only.

Commit 41c1285

Browse files
author
Fathy Boundjadj
authored
fix(cookies): null values should delete cookies (#130)
1 parent 2d4c74a commit 41c1285

File tree

4 files changed

+11
-2
lines changed

4 files changed

+11
-2
lines changed

HISTORY.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# 3.13.2 / 2020-05-21
2+
3+
- fix: null values should delete cookies
4+
15
# 3.13.1 / 2020-05-04
26

37
- refactor: remove third party dependency ndhoule/each

lib/cookie.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ Cookie.prototype.options = function(options) {
7373
Cookie.prototype.set = function(key, value) {
7474
try {
7575
value = window.JSON.stringify(value);
76-
cookie(key, value, clone(this._options));
76+
cookie(key, value === 'null' ? null : value, clone(this._options));
7777
return true;
7878
} catch (e) {
7979
return false;

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@segment/analytics.js-core",
33
"author": "Segment <[email protected]>",
4-
"version": "3.13.1",
4+
"version": "3.13.2",
55
"description": "The hassle-free way to integrate analytics into any web application.",
66
"keywords": [
77
"analytics",

test/cookie.test.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ describe('cookie', function() {
4949
cookie.remove('cookie-remove');
5050
assert(cookie.get('cookie-remove') === null);
5151
});
52+
53+
it('null cookie should be null after setting', function() {
54+
cookie.set('cookie-null', null);
55+
assert(cookie.get('cookie-null') === null);
56+
});
5257
});
5358

5459
describe('#options', function() {

0 commit comments

Comments
 (0)