Last active
September 20, 2024 22:39
-
-
Save allenhwkim/19c2f36a7afa6f0c507008613e966d1b to your computer and use it in GitHub Desktop.
Cookie Class
there's a bug in getAll where it fails if the cookie value contains =
(which is legal in cookie values), for example it would fail on the cookie
c1=foo=bar; c2=anything
with get("c1") incorrectly returning foo
instead of foo=bar
to fix it, replace
let [k,v] = el.split('=');
cookie[k.trim()] = v;
with
const split = el.split('=');
cookie[parts[0].trim()] = parts.slice(1).join("=");
there's a bug in getAll where it fails if the cookie value contains
=
(which is legal in cookie values), for example it would fail on the cookie
...
Updated with
let [k, ...v] = el.split('=');
cookie[k.trim()] = v.join('=');
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks