cookies icon indicating copy to clipboard operation
cookies copied to clipboard

Require cookie value to be string (unset omitted or null)

Open zachasme opened this issue 6 years ago • 2 comments

Resolves #101.

This enforces string input as suggested by @dougwilson.

Two considerations:

  • Is input a string if wrapped in String constructor? I suggest no, as do Node. That is also what I went with in the PR.
  • When is input omitted? Logically undefined. But there are tests for expiring cookies using null. What about false? I feel undefined and null should cover it (an explicit Cookies.remove would avoid ambiguity, see #98).

zachasme avatar Sep 11 '19 09:09 zachasme

Is input a string if wrapped in String constructor? I suggest no, as do Node. That is also what I went with in the PR.

Yea, I have just done the same type of validations that Node.js APIs use, which is just typeof, only considering primitive types and not the boxed types.

When is input omitted? Logically undefined. But there are tests for expiring cookies using null. What about false? I feel undefined and null should cover it

From a JavaScript POV, it is just undefined. The two tests passing in null, are testing that any falsy value works, so that would mean the API contract there does indeed false and 0.

dougwilson avatar Feb 15 '20 23:02 dougwilson

Would you prefer only considering input as omitted on undefined then? If so I can quickly update the PR accordingly.

zachasme avatar Feb 17 '20 08:02 zachasme