Skip to content

Commit f8e01f4

Browse files
dimacFagnerMartinsBrack
authored andcommitted
false secure option should not modify the cookie path
Closes js-cookiegh-54.
1 parent dbfe7e8 commit f8e01f4

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/js.cookie.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
attributes.expires && '; expires=' + attributes.expires.toUTCString(), // use expires attribute, max-age is not supported by IE
6868
attributes.path && '; path=' + attributes.path,
6969
attributes.domain && '; domain=' + attributes.domain,
70-
attributes.secure && '; secure'
70+
attributes.secure ? '; secure' : ''
7171
].join(''));
7272
}
7373

test/tests.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,14 @@ QUnit.test('API for changing defaults', function (assert) {
174174
assert.ok(Cookies.set('c', 'v').match(/path=\//), 'should roll back to the default path');
175175
});
176176

177+
// github.com/js-cookie/js-cookie/pull/54
178+
QUnit.test('false secure value', function (assert) {
179+
assert.expect(1);
180+
var expected = 'c=v; path=/';
181+
var actual = Cookies.set('c', 'v', {secure: false});
182+
assert.strictEqual(actual, expected, 'false should not modify path in cookie string');
183+
});
184+
177185
QUnit.module('remove', lifecycle);
178186

179187
QUnit.test('deletion', function (assert) {

0 commit comments

Comments
 (0)