Merge pull request #5 from sliterok/patch-1

Moved definition of CookieJar.cookies because it caused TypeError on constructor
This commit is contained in:
jkhsjdhjs 2020-05-31 15:02:00 +02:00 committed by GitHub
commit 7d3393d9e5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -5,6 +5,8 @@ import {paramError, CookieParseError} from "./errors.mjs";
export default class CookieJar { export default class CookieJar {
constructor(file, flags = "rw", cookies, cookieIgnoreCallback) { constructor(file, flags = "rw", cookies, cookieIgnoreCallback) {
this.cookies = new Map();
if(file && typeof file !== "string") if(file && typeof file !== "string")
throw paramError("Second", "file", "new CookieJar()", "string"); throw paramError("Second", "file", "new CookieJar()", "string");
if(typeof flags !== "string") if(typeof flags !== "string")
@ -22,7 +24,6 @@ export default class CookieJar {
throw paramError("Fourth", "cookieIgnoreCallback", "new CookieJar()", "function"); throw paramError("Fourth", "cookieIgnoreCallback", "new CookieJar()", "function");
this.file = file; this.file = file;
this.flags = flags; this.flags = flags;
this.cookies = new Map();
this.cookieIgnoreCallback = cookieIgnoreCallback; this.cookieIgnoreCallback = cookieIgnoreCallback;
} }
addCookie(cookie, fromURL) { addCookie(cookie, fromURL) {