CookieJar.toJSON() method doesn't preserve looseMode flag. Thus, setting an invalid cookie throws an error (after creating a new instance using fromJSON()).
Reproduceable code:
const { CookieJar } = require('tough-cookie');
const url = 'http://random.com';
const cookie = 'Invalid Cookie;';
const cookieJar = new CookieJar(null, { looseMode: true });
const deserializedCookieJar = CookieJar.fromJSON(cookieJar.toJSON());
deserializedCookieJar.setCookieSync(cookie, url);
// ^ throws "Error: Cookie failed to parse"
CookieJar.toJSON()method doesn't preserve looseMode flag. Thus, setting an invalid cookie throws an error (after creating a new instance usingfromJSON()).Reproduceable code: