http-cookie-agent
Advanced tools
Comparing version 1.0.2 to 1.0.3
@@ -8,3 +8,3 @@ "use strict"; | ||
const url_1 = __importDefault(require("url")); | ||
const cookie_1 = __importDefault(require("cookie")); | ||
const tough_cookie_1 = require("tough-cookie"); | ||
const GET_REQUEST_URL = Symbol('getRequestUrl'); | ||
@@ -33,16 +33,18 @@ const SET_COOKIE_HEADER = Symbol('setCookieHeader'); | ||
const cookies = await this.jar.getCookies(requestUrl); | ||
const cookiesEntries = cookies.map((cookie) => [cookie.key, cookie.value]); | ||
const cookieHeaderFromRequest = req.getHeader('Cookie'); | ||
if (Array.isArray(cookieHeaderFromRequest)) { | ||
for (const str of cookieHeaderFromRequest) { | ||
const cookie = cookie_1.default.parse(str); | ||
cookiesEntries.push(...Object.entries(cookie)); | ||
const cookiesMap = new Map(cookies.map((cookie) => [cookie.key, cookie])); | ||
const cookieHeaderList = [req.getHeader('Cookie')].flat(); | ||
for (const header of cookieHeaderList) { | ||
if (typeof header !== 'string') { | ||
continue; | ||
} | ||
for (const str of header.split(';')) { | ||
const cookie = tough_cookie_1.Cookie.parse(str.trim()); | ||
if (cookie === undefined) { | ||
continue; | ||
} | ||
cookiesMap.set(cookie.key, cookie); | ||
} | ||
} | ||
else if (typeof cookieHeaderFromRequest === 'string') { | ||
const cookie = cookie_1.default.parse(cookieHeaderFromRequest); | ||
cookiesEntries.push(...Object.entries(cookie)); | ||
} | ||
const cookieHeader = Array.from(new Map(cookiesEntries)) | ||
.map(([key, value]) => cookie_1.default.serialize(key, value)) | ||
const cookieHeader = Array.from(cookiesMap.values()) | ||
.map((cookie) => cookie.cookieString()) | ||
.join(';\x20'); | ||
@@ -49,0 +51,0 @@ return cookieHeader; |
{ | ||
"name": "http-cookie-agent", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "Allows cookies with every Node.js HTTP clients.", | ||
@@ -30,4 +30,3 @@ "license": "MIT", | ||
"dependencies": { | ||
"agent-base": "^6.0.2", | ||
"cookie": "^0.4.1" | ||
"agent-base": "^6.0.2" | ||
}, | ||
@@ -42,6 +41,5 @@ "peerDependencies": { | ||
"@semantic-release/git": "9.0.1", | ||
"@types/cookie": "0.4.1", | ||
"@types/http-proxy": "1.17.7", | ||
"@types/needle": "2.5.2", | ||
"@types/node": "12.20.33", | ||
"@types/node": "12.20.36", | ||
"@types/node-fetch": "2.5.12", | ||
@@ -53,3 +51,3 @@ "@types/request": "2.48.7", | ||
"ava": "3.15.0", | ||
"axios": "0.22.0", | ||
"axios": "0.24.0", | ||
"got": "11.8.2", | ||
@@ -66,3 +64,3 @@ "http-proxy": "1.18.1", | ||
"tough-cookie": "4.0.0", | ||
"typescript": "4.4.3", | ||
"typescript": "4.4.4", | ||
"urllib": "2.37.4" | ||
@@ -69,0 +67,0 @@ }, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2
27
190
18099
- Removedcookie@^0.4.1
- Removedcookie@0.4.2(transitive)