Fix issue and appease linter
This commit is contained in:
parent
77b9408935
commit
3fa4e05468
@ -3,7 +3,7 @@ import { performance } from "perf_hooks";
|
||||
import { getServiceItem } from "utils/config/service-helpers";
|
||||
import createLogger from "utils/logger";
|
||||
import { httpProxy } from "utils/proxy/http";
|
||||
import {importCookieHeader} from "../../utils/proxy/cookie-jar";
|
||||
import {importCookieHeader} from "utils/proxy/cookie-jar";
|
||||
|
||||
const logger = createLogger("ping");
|
||||
|
||||
|
||||
@ -39,10 +39,20 @@ export function addCookieToJar(url, headers) {
|
||||
}
|
||||
|
||||
export function importCookieHeader(url, cookieHeader) {
|
||||
for (const cookiePair of cookieHeader.split(';')) {
|
||||
const [key, value] = cookiePair.trim().split('=')
|
||||
const cookies = cookieHeader.split(';')
|
||||
for (let i = 0; i < cookies.length; i += 1) {
|
||||
const [key, value] = cookies[i].trim().split('=')
|
||||
|
||||
// If there's an existing cookie with a matching key for this url,
|
||||
// we want to update it
|
||||
const existingCookie = cookieJar.getCookiesSync(url).find(existing => existing.key === key)
|
||||
if (existingCookie) {
|
||||
existingCookie.value = value;
|
||||
} else {
|
||||
// Otherwise we add a new cookie
|
||||
cookieJar.setCookieSync(new Cookie({
|
||||
key, value
|
||||
}), url.toString(), { ignoreError: true });
|
||||
}), url.toString(), { ignoreError: false });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,7 +4,7 @@ import validateWidgetData from "utils/proxy/validate-widget-data";
|
||||
import { httpProxy } from "utils/proxy/http";
|
||||
import createLogger from "utils/logger";
|
||||
import widgets from "widgets/widgets";
|
||||
import {importCookieHeader} from "../cookie-jar";
|
||||
import {importCookieHeader} from "utils/proxy/cookie-jar";
|
||||
|
||||
const logger = createLogger("genericProxyHandler");
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user