Skip to content

Instantly share code, notes, and snippets.

@allenhwkim
Last active December 11, 2023 08:59
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save allenhwkim/19c2f36a7afa6f0c507008613e966d1b to your computer and use it in GitHub Desktop.
Save allenhwkim/19c2f36a7afa6f0c507008613e966d1b to your computer and use it in GitHub Desktop.
Cookie Class
@doguscancalli
Copy link

Thanks

@divinity76
Copy link

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("=");

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment