How to use the tough-cookie.cookieCompare function in tough-cookie

To help you get started, we’ve selected a few tough-cookie examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github assaf / zombie / src / cookies.js View on Github external
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);
  }
github assaf / zombie / src / browser.js View on Github external
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';
  }