Skip to content

Commit bc4b822

Browse files
Create the default path attribute implementation
1 parent 6ff48c8 commit bc4b822

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/js.cookie.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,9 @@
118118
json: true
119119
}, [].slice.call(arguments));
120120
};
121-
api.defaults = {};
121+
api.defaults = {
122+
path: '/'
123+
};
122124

123125
api.remove = function (key, options) {
124126
api(key, '', extend(options, {

test/tests.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,12 @@ test('return value', function () {
162162
strictEqual(actual, expected, 'should return written cookie string');
163163
});
164164

165-
test('defaults', function () {
165+
test('default path attribute', function () {
166+
expect(1);
167+
ok(Cookies.set('c', 'v').match(/path=\//), 'should be default to the whole site');
168+
});
169+
170+
test('changing defaults', function () {
166171
expect(2);
167172

168173
Cookies.defaults.path = '/foo';

0 commit comments

Comments
 (0)