angular-cookie icon indicating copy to clipboard operation
angular-cookie copied to clipboard

Set cookie "1.0", it returns 1 instead of "1.0"

Open JobaDiniz opened this issue 10 years ago • 1 comments

I set a string containing "1.0" and it treats like a number, but it should be string.

Plunker: http://plnkr.co/edit/LKDa49lsomvHGMaycWtE

  1. Click "Set Cookie"
  2. Click "Get Cookie"
  3. Check the last item showed. It should be "1.0"

JobaDiniz avatar Aug 22 '14 14:08 JobaDiniz

Yeah, it's running all values through a JSON.parse, which converts strings to numbers.

I'm having an issue where some of my strings coincidentally match the exponential format, e.g.

ipCookie('testCookie', "123581763871623871628361723e12341");
console.log(ipCookie('testCookie')); // Logs Infinity

The library is trying to do too much. Just store strings and let the user figure out serialization and deserialization.

bmnielsen avatar Nov 18 '14 10:11 bmnielsen