Skip to content

Commit 1f40fcb

Browse files
committed
fix(cookies): set default cookie path to /
1 parent 02ac7b1 commit 1f40fcb

File tree

4 files changed

+21
-11
lines changed

4 files changed

+21
-11
lines changed

.size-snapshot.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
{
22
"dist/streamsql.esm.js": {
3-
"bundled": 8662,
4-
"minified": 4273,
5-
"gzipped": 1705,
3+
"bundled": 8725,
4+
"minified": 4301,
5+
"gzipped": 1721,
66
"treeshaked": {
77
"rollup": {
88
"code": 75,
99
"import_statements": 0
1010
},
1111
"webpack": {
12-
"code": 4866
12+
"code": 4894
1313
}
1414
}
1515
},
1616
"dist/streamsql.cjs.js": {
17-
"bundled": 10213,
18-
"minified": 4843,
19-
"gzipped": 1782
17+
"bundled": 10276,
18+
"minified": 4871,
19+
"gzipped": 1798
2020
},
2121
"dist/streamsql.min.js": {
22-
"bundled": 11154,
23-
"minified": 4647,
24-
"gzipped": 1748
22+
"bundled": 11227,
23+
"minified": 4675,
24+
"gzipped": 1765
2525
}
2626
}

integration/fixtures/streamsql.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Cookies.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ export default class CookieJar implements CookieHandler {
4747
oneYearFromNow.setFullYear(oneYearFromNow.getFullYear() + 1)
4848
cookieOpts.expires = oneYearFromNow.toUTCString()
4949
}
50+
cookieOpts.path = cookieOpts.path || '/'
5051
cookieOpts.secure = true
5152
cookieOpts.sameSite = SameSite.None
5253
this.simpleCookies.set(cookieOpts.name, cookieOpts.value)
@@ -85,6 +86,7 @@ export default class CookieJar implements CookieHandler {
8586
this.setCookie({
8687
name,
8788
value: '',
89+
path: '/',
8890
maxAge: 0,
8991
expires: epoch.toUTCString()
9092
})

src/test/cookies.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,14 @@ describe('CookieHandler', () => {
7676
expect(document.cookie).toMatch('Secure')
7777
})
7878

79+
it('sets default cookie path to /', () => {
80+
ch.setCookie({
81+
name: 'name',
82+
value: 'value',
83+
})
84+
expect(document.cookie).toMatch('Path=/')
85+
})
86+
7987
it('overrides default domain and path when set in options', () => {
8088
ch.setCookie({
8189
name: 'name',

0 commit comments

Comments
 (0)