Open blakeembrey opened 1 month ago
This would insta-break everyone and is too big of a change I think, but you are the maintainer 😄
I actually wanted to ask about this, why not just do this to fix #60:
- // only assign once
- if (!__hasOwnProperty.call(obj, key)) {
let valStartIdx = startIndex(str, eqIdx + 1, endIdx);
let valEndIdx = endIndex(str, endIdx, valStartIdx);
if (
str.charCodeAt(valStartIdx) === 0x22 /* " */ &&
str.charCodeAt(valEndIdx - 1) === 0x22 /* " */
) {
valStartIdx++;
valEndIdx--;
}
const val = str.slice(valStartIdx, valEndIdx);
obj[key] = tryDecode(val, dec);
- }
Cookie: name=value; name=value2;
We'd have name: value2
, which makes more sense to me than taking the first
I actually wanted to ask about this
I have no preference over keeping last vs first, but I'd be in favor of removing an extra check every iteration (with the possible downside of an extra decode). It seems unordered though, so I don't think that will solve #60. You'd need a way to getAll
.
I think this is the relevant piece:
2. The user agent SHOULD sort the cookie-list in the following
order:
* Cookies with longer paths are listed before cookies with
shorter paths.
* Among cookies that have equal-length path fields, cookies with
earlier creation-times are listed before cookies with later
creation-times.
NOTE: Not all user agents sort the cookie-list in this order, but
this order reflects common practice when this document was
written, and, historically, there have been servers that
(erroneously) depended on this order.
I think you'd want the longest path (most specific) cookie?
Hello I'm new
You are hackers
Another RFC (cc @gurgunday). This would resolve #60, but is a larger breaking change. There is a perf improvement that kicks in when you have a couple of cookies:
After:
Before: