From 68a508fcd070e20f42e02842569db0145e39050c Mon Sep 17 00:00:00 2001 From: Alex Yang Date: Fri, 10 May 2024 11:07:40 -0700 Subject: [PATCH] test: fix check host (#829) --- packages/core/tests/vitest.setup.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/core/tests/vitest.setup.ts b/packages/core/tests/vitest.setup.ts index 97e4d04e57..a6a100a6ec 100644 --- a/packages/core/tests/vitest.setup.ts +++ b/packages/core/tests/vitest.setup.ts @@ -11,8 +11,8 @@ globalThis.fetch = function fetch(...args: Parameters) { url = url.toString(); } } - const parsedUrl = new URL(url); - if (parsedUrl.hostname.includes("openai.com")) { + const { host } = new URL(url); + if (host.endsWith("openai.com")) { // todo: mock api using https://mswjs.io throw new Error( "Make sure to return a mock response for OpenAI API requests in your test.",