diff --git a/src/index.ts b/src/index.ts index 23fe8ea..fbd231d 100644 --- a/src/index.ts +++ b/src/index.ts @@ -301,7 +301,7 @@ export function stringifySetCookie( let str = cookie.name + "=" + value; if (cookie.maxAge !== undefined) { - if (!Number.isInteger(cookie.maxAge)) { + if (!Number.isSafeInteger(cookie.maxAge)) { throw new TypeError(`option maxAge is invalid: ${cookie.maxAge}`); } diff --git a/src/stringify-set-cookie.spec.ts b/src/stringify-set-cookie.spec.ts index f4e9cd4..e709e63 100644 --- a/src/stringify-set-cookie.spec.ts +++ b/src/stringify-set-cookie.spec.ts @@ -181,6 +181,7 @@ describe("cookie.stringifySetCookie", () => { ["non-number", "buzz"], ["Infinity", Infinity], ["non-integer", 3.14], + ["unsafe integer", 1e21], ])("should throw when maxAge is %s", (_label, maxAge) => { expect(() => stringifySetCookie({ name: "foo", value: "bar", maxAge } as any),