mirror of
https://github.com/Kong/insomnia.git
synced 2026-05-19 14:23:03 -04:00
chore(sdk): avoid invalid cookie blocking sending request (#8464)
This commit is contained in:
@@ -2,6 +2,7 @@ import type { Cookie as InsomniaCookie, CookieJar as InsomniaCookieJar } from 'i
|
||||
import { Cookie as ToughCookie } from 'tough-cookie';
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
|
||||
import { getExistingConsole } from './console';
|
||||
import { Property, PropertyList } from './properties';
|
||||
|
||||
export interface InsomniaCookieExtensions {
|
||||
@@ -242,7 +243,7 @@ export class CookieObject extends CookieList {
|
||||
}
|
||||
|
||||
export class CookieJar {
|
||||
// CookieJar from tough-cookie can not be used, as it will failed in comparing context location and cookies' domain
|
||||
// CookieJar from tough-cookie can not be used, as it will fail in comparing context location and cookies' domain
|
||||
// as it reads location from the browser window, it is "localhost"
|
||||
private jar: Map<string, Map<string, Cookie>>; // Map<domain, Map<cookieKey, cookieObject>>
|
||||
private jarName: string;
|
||||
@@ -255,7 +256,8 @@ export class CookieJar {
|
||||
cookies.forEach(cookie => {
|
||||
const properties = cookie.toJSON();
|
||||
if (!properties.domain) {
|
||||
throw Error(`domain is not specified for the cookie ${cookie.key}`);
|
||||
getExistingConsole().warn(`domain is not specified for the cookie "${cookie.key}" so it is omitted`);
|
||||
return;
|
||||
}
|
||||
|
||||
const domainCookies = this.jar.get(properties.domain) || new Map();
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { getExistingConsole } from './console';
|
||||
import { Property, PropertyList } from './properties';
|
||||
import { Url, UrlMatchPattern, UrlMatchPatternList } from './urls';
|
||||
|
||||
@@ -202,7 +203,7 @@ export function transformToSdkProxyOptions(
|
||||
if (bestProxy !== '') {
|
||||
let sanitizedProxy = bestProxy;
|
||||
if (bestProxy.indexOf('://') === -1) {
|
||||
console.warn(`The protocol is missing and adding 'https:' protocol: ${bestProxy}`);
|
||||
getExistingConsole().warn(`The protocol is missing for proxy, 'https:' is enabled for: ${bestProxy}`);
|
||||
sanitizedProxy = 'https://' + bestProxy;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user