Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
select(identifier) {
let cookies = this.filter(cookie => cookie.TTL() > 0); // eslint-disable-line new-cap
if (identifier.name)
cookies = cookies.filter(cookie => cookie.key === identifier.name);
if (identifier.path)
cookies = cookies.filter(cookie => Tough.pathMatch(identifier.path, cookie.path));
if (identifier.domain)
cookies = cookies.filter(cookie => Tough.domainMatch(identifier.domain, cookie.domain));
return cookies
.sort((a, b)=> b.domain.length - a.domain.length)
.sort(Tough.cookieCompare);
}
saveCookies() {
const serialized = [`# Saved on ${new Date().toISOString()}`];
for (let cookie of this.cookies.sort(Tough.cookieCompare))
serialized.push(cookie.toString());
return serialized.join('\n') + '\n';
}