Skip to content

Commit 6333468

Browse files
committed
fix setCookie (fails when options.expires is not set or is not a Date)
1 parent c5fa0e7 commit 6333468

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

6-data-storage/01-cookie/article.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ function setCookie(name, value, options = {}) {
311311
...options
312312
};
313313

314-
if (options.expires.toUTCString) {
314+
if (options.expires instanceof Date && options.expires.toUTCString) {
315315
options.expires = options.expires.toUTCString();
316316
}
317317

6-data-storage/01-cookie/cookie.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ function setCookie(name, value, options = {}) {
1313
...options
1414
};
1515

16-
if (options.expires.toUTCString) {
16+
if (options.expires instanceof Date && options.expires.toUTCString) {
1717
options.expires = options.expires.toUTCString();
1818
}
1919

0 commit comments

Comments
 (0)