Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
module.exports.jarFromCookies = function(cookies) {
let jar;
try {
// For some reason, fromJSON modifies `cookies`. Create a copy first
// just to be sure
const copy = JSON.stringify({ cookies });
jar = CookieJar.fromJSON(copy);
} catch (e) {
console.log('[cookies] Failed to initialize cookie jar', e);
jar = new CookieJar();
}
jar.rejectPublicSuffixes = false;
jar.looseMode = true;
return jar;
};