Skip to content

Commit c66147c

Browse files
authored
Overwrite value in passed in options (#253)
1 parent 09cec9f commit c66147c

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ export function stringifySetCookie(
293293
const cookie =
294294
typeof _name === "object"
295295
? _name
296-
: { name: _name, value: String(_val), ..._opts };
296+
: { ..._opts, name: _name, value: String(_val) };
297297
const options = typeof _val === "object" ? _val : _opts;
298298
const enc = options?.encode || encodeURIComponent;
299299

src/stringify-set-cookie.spec.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ describe("cookie.stringifySetCookie", function () {
3535
).toEqual("foo=bar+baz");
3636
});
3737

38+
it("should support three argument mode with value in options", function () {
39+
expect(
40+
cookie.stringifySetCookie("foo", "test", { value: "ignored" } as any),
41+
).toEqual("foo=test");
42+
});
43+
3844
it.each([
3945
["foo"],
4046
["foo,bar"],

0 commit comments

Comments
 (0)