Skip to content

Commit c113e8b

Browse files
authored
Merge pull request #7 from Constructor-io/noch/path-fix
Add semicolon
2 parents d4d8dd0 + ce55d28 commit c113e8b

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

spec/006-cookies.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ describe('ConstructorioID', function () {
1717
});
1818

1919
describe('set_cookie', function () {
20-
it('should create a cookie', function () {
20+
it('should create a cookie with a valid path', function () {
2121
var session = new ConstructorioID();
22-
session.set_cookie('mewantcookie', 'meeatcookie');
23-
expect(global.document.cookie).to.match(/mewantcookie=meeatcookie/);
22+
var cookieData = session.set_cookie('mewantcookie', 'meeatcookie');
23+
expect(cookieData).to.match(/mewantcookie=meeatcookie; expires=.*; path=\//);
2424
});
2525
});
2626

src/constructorio-id.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,14 @@
4242
ConstructorioID.prototype.set_cookie = function (name, value) {
4343
if (!this.on_node && this.persist) {
4444
var expires = new Date(Date.now() + this.cookie_days_to_live * 24 * 60 * 60 * 1000);
45-
var cookie_data = name + '=' + value + '; expires=' + expires.toUTCString() + ' path=/';
45+
var cookie_data = name + '=' + value + '; expires=' + expires.toUTCString() + '; path=/';
4646
if (this.cookie_domain) {
4747
cookie_data += '; domain=' + this.cookie_domain;
4848
}
4949
document.cookie = cookie_data;
50+
51+
// For testing purposes
52+
return cookie_data;
5053
}
5154
};
5255

0 commit comments

Comments
 (0)