filter cookies with same names before sending

duplicate names may occur if we store cookies with the same name for example.com with subdomains and for sub.example.com
This commit is contained in:
2019-08-14 00:38:11 +02:00
parent 14a874f208
commit f613a8c32e
3 changed files with 3 additions and 2 deletions

View File

@ -16,6 +16,7 @@ async function cookieFetch(cookieJars, url, options) {
domains
.map(d => [...jar.iterValidForRequest(d, url)])
.reduce((a, b) => [...a, ...b])
.filter((v, i, a) => a.slice(0, i).every(c => c.name !== v.name)) //unique
.forEach(c => cookies += c.serialize() + "; ");
if(cookieJars) {
if(Array.isArray(cookieJars) && cookieJars.every(c => c instanceof CookieJar)) {