index: shorten code

This commit is contained in:
jkhsjdhjs 2020-06-17 15:35:44 +02:00
parent 0ef1ff3194
commit da938955f5
Signed by: jkhsjdhjs
GPG Key ID: BAC6ADBAB7D576CC

View File

@ -8,15 +8,14 @@ const redirectStatus = new Set([301, 302, 303, 307, 308]);
const cookieJar = new CookieJar(); const cookieJar = new CookieJar();
export default async function fetch(url, options) { export default async function fetch(url, options) {
let cookies = ""; let cookies = [...cookieJar.cookiesValidForRequest(url)]
[...cookieJar.cookiesValidForRequest(url)].forEach( .map(c => c.serialize())
c => (cookies += c.serialize() + "; ") .join("; ");
);
if (cookies) { if (cookies) {
if (!options) options = {}; if (!options) options = {};
if (!options.headers) options.headers = {}; if (!options.headers) options.headers = {};
options.headers.cookie = cookies.slice(0, -2); options.headers.cookie = cookies;
} }
const wantFollow = const wantFollow =