tough-cookie
Advanced tools
Comparing version 2.1.0 to 2.2.0
@@ -881,6 +881,14 @@ /*! | ||
function CookieJar(store, rejectPublicSuffixes) { | ||
if (rejectPublicSuffixes != null) { | ||
this.rejectPublicSuffixes = rejectPublicSuffixes; | ||
function CookieJar(store, options) { | ||
if (typeof options === "boolean") { | ||
options = {rejectPublicSuffixes: options}; | ||
} else if (options == null) { | ||
options = {}; | ||
} | ||
if (options.rejectPublicSuffixes != null) { | ||
this.rejectPublicSuffixes = options.rejectPublicSuffixes; | ||
} | ||
if (options.looseMode != null) { | ||
this.enableLooseMode = options.looseMode; | ||
} | ||
@@ -894,2 +902,3 @@ if (!store) { | ||
CookieJar.prototype.rejectPublicSuffixes = true; | ||
CookieJar.prototype.enableLooseMode = false; | ||
var CAN_BE_SYNC = []; | ||
@@ -907,6 +916,10 @@ | ||
var host = canonicalDomain(context.hostname); | ||
var loose = this.enableLooseMode; | ||
if (options.loose != null) { | ||
loose = options.loose; | ||
} | ||
// S5.3 step 1 | ||
if (!(cookie instanceof Cookie)) { | ||
cookie = Cookie.parse(cookie, { loose: options.loose }); | ||
cookie = Cookie.parse(cookie, { loose: loose }); | ||
} | ||
@@ -913,0 +926,0 @@ if (!cookie) { |
@@ -46,3 +46,3 @@ { | ||
], | ||
"version": "2.1.0", | ||
"version": "2.2.0", | ||
"homepage": "https://github.com/SalesforceEng/tough-cookie", | ||
@@ -49,0 +49,0 @@ "repository": { |
@@ -240,12 +240,12 @@ [RFC6265](https://tools.ietf.org/html/rfc6265) Cookies and CookieJar for Node.js | ||
### `CookieJar([store],[rejectPublicSuffixes])` | ||
### `CookieJar([store],[options])` | ||
Simply use `new CookieJar()`. If you'd like to use a custom store, pass that to the constructor otherwise a `MemoryCookieStore` will be created and used. | ||
### Properties | ||
The `options` object can be omitted and can have the following properties: | ||
CookieJar object properties: | ||
* _rejectPublicSuffixes_ - boolean - default `true` - reject cookies with domains like "com" and "co.uk" | ||
* _looseMode_ - boolean - default `false` - accept malformed cookies like `bar` and `=bar`, which have an implied empty name. | ||
This is not in the standard, but is used sometimes on the web and is accepted by (most) browsers. | ||
* _rejectPublicSuffixes_ - boolean - reject cookies with domains like "com" and "co.uk" (default: `true`) | ||
Since eventually this module would like to support database/remote/etc. CookieJars, continuation passing style is used for CookieJar methods. | ||
@@ -252,0 +252,0 @@ |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
229039
2133
1