From 056a4bcf4c68de4b71f7a8ebe014fb3bb59eb12a Mon Sep 17 00:00:00 2001 From: George He Date: Thu, 20 Mar 2025 10:41:12 +0800 Subject: [PATCH] chore(sdk): avoid invalid cookie blocking sending request (#8464) --- packages/insomnia-sdk/src/objects/cookies.ts | 6 ++++-- packages/insomnia-sdk/src/objects/proxy-configs.ts | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/insomnia-sdk/src/objects/cookies.ts b/packages/insomnia-sdk/src/objects/cookies.ts index c320af9f0f..ccae2aa945 100644 --- a/packages/insomnia-sdk/src/objects/cookies.ts +++ b/packages/insomnia-sdk/src/objects/cookies.ts @@ -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>; // Map> 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(); diff --git a/packages/insomnia-sdk/src/objects/proxy-configs.ts b/packages/insomnia-sdk/src/objects/proxy-configs.ts index 74a93d97f3..6d4388be70 100644 --- a/packages/insomnia-sdk/src/objects/proxy-configs.ts +++ b/packages/insomnia-sdk/src/objects/proxy-configs.ts @@ -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; }