Add missing path=/ to setCookieWithoutExpiration
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -50,7 +50,7 @@ export function setCookie(name, value, days=1) {
|
|||||||
* @param {string} value - The cookie value.
|
* @param {string} value - The cookie value.
|
||||||
*/
|
*/
|
||||||
export function setCookieWithoutExpiration(name, value) {
|
export function setCookieWithoutExpiration(name, value) {
|
||||||
document.cookie = name + "=" + (value || "") + "; Secure; SameSite=Lax";
|
document.cookie = name + "=" + (value || "") + "; path=/; Secure; SameSite=Lax";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -82,6 +82,15 @@ describe('cookieUtil', () => {
|
|||||||
expect(str).toContain('Secure');
|
expect(str).toContain('Secure');
|
||||||
expect(str).toContain('SameSite=Lax');
|
expect(str).toContain('SameSite=Lax');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('sets cookie with path=/', () => {
|
||||||
|
setCookieWithoutExpiration('pathKey', 'pathVal');
|
||||||
|
|
||||||
|
const written = cookieSetter.mock.calls.find(
|
||||||
|
(c) => c[0].startsWith('pathKey='),
|
||||||
|
);
|
||||||
|
expect(written[0]).toContain('path=/');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('deleteCookie', () => {
|
describe('deleteCookie', () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user