fix TypeError when passing a CookieJar without the "r" flag to fetch

bump patch version to 1.3.5
This commit is contained in:
jkhsjdhjs 2020-02-14 10:03:30 +01:00
parent f18fc55999
commit ba2f52ae08
Signed by: jkhsjdhjs
GPG Key ID: BAC6ADBAB7D576CC
3 changed files with 5 additions and 4 deletions

2
package-lock.json generated
View File

@ -1,6 +1,6 @@
{ {
"name": "node-fetch-cookies", "name": "node-fetch-cookies",
"version": "1.3.4", "version": "1.3.5",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {

View File

@ -1,6 +1,6 @@
{ {
"name": "node-fetch-cookies", "name": "node-fetch-cookies",
"version": "1.3.4", "version": "1.3.5",
"description": "node-fetch wrapper that adds support for cookie-jars", "description": "node-fetch wrapper that adds support for cookie-jars",
"main": "src/index.mjs", "main": "src/index.mjs",
"engines": { "engines": {

View File

@ -19,7 +19,8 @@ async function fetch(cookieJars, url, options) {
if(cookieJars) { if(cookieJars) {
if(Array.isArray(cookieJars) && cookieJars.every(c => c instanceof CookieJar)) if(Array.isArray(cookieJars) && cookieJars.every(c => c instanceof CookieJar))
addValidFromJars(cookieJars.filter(jar => jar.flags.includes("r"))); addValidFromJars(cookieJars.filter(jar => jar.flags.includes("r")));
else if(cookieJars instanceof CookieJar && cookieJars.flags.includes("r")) else if(cookieJars instanceof CookieJar)
if(cookieJars.flags.includes("r"))
addValidFromJars([cookieJars]); addValidFromJars([cookieJars]);
else else
throw paramError("First", "cookieJars", "fetch", ["CookieJar", "[CookieJar]"]); throw paramError("First", "cookieJars", "fetch", ["CookieJar", "[CookieJar]"]);