From 341e3452cd81981e1569358637eec8fd618af426 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Sun, 15 Feb 2026 04:49:35 +0000 Subject: [PATCH] Cover trimmed ws and wss baseURL rejection Co-authored-by: Eric Allam --- packages/ai/src/chatTransport.test.ts | 44 +++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/packages/ai/src/chatTransport.test.ts b/packages/ai/src/chatTransport.test.ts index 6177740fc..a5985f7cd 100644 --- a/packages/ai/src/chatTransport.test.ts +++ b/packages/ai/src/chatTransport.test.ts @@ -664,6 +664,17 @@ describe("TriggerChatTransport", function () { }).toThrowError("baseURL must use http or https protocol"); }); + it("throws when trimmed baseURL protocol is ws", function () { + expect(function () { + new TriggerChatTransport({ + task: "chat-task", + accessToken: "pk_trigger", + baseURL: " ws://example.com ", + stream: "chat-stream", + }); + }).toThrowError("baseURL must use http or https protocol"); + }); + it("throws when baseURL protocol is wss", function () { expect(function () { new TriggerChatTransport({ @@ -675,6 +686,17 @@ describe("TriggerChatTransport", function () { }).toThrowError("baseURL must use http or https protocol"); }); + it("throws when trimmed baseURL protocol is wss", function () { + expect(function () { + new TriggerChatTransport({ + task: "chat-task", + accessToken: "pk_trigger", + baseURL: " wss://example.com ", + stream: "chat-stream", + }); + }).toThrowError("baseURL must use http or https protocol"); + }); + it("throws when baseURL includes query parameters", function () { expect(function () { new TriggerChatTransport({ @@ -2991,6 +3013,17 @@ describe("TriggerChatTransport", function () { }).toThrowError("baseURL must use http or https protocol"); }); + it("throws from factory when trimmed baseURL protocol is ws", function () { + expect(function () { + createTriggerChatTransport({ + task: "chat-task", + accessToken: "pk_trigger", + baseURL: " ws://example.com ", + stream: "chat-stream", + }); + }).toThrowError("baseURL must use http or https protocol"); + }); + it("throws from factory when baseURL protocol is wss", function () { expect(function () { createTriggerChatTransport({ @@ -3002,6 +3035,17 @@ describe("TriggerChatTransport", function () { }).toThrowError("baseURL must use http or https protocol"); }); + it("throws from factory when trimmed baseURL protocol is wss", function () { + expect(function () { + createTriggerChatTransport({ + task: "chat-task", + accessToken: "pk_trigger", + baseURL: " wss://example.com ", + stream: "chat-stream", + }); + }).toThrowError("baseURL must use http or https protocol"); + }); + it("throws from factory when baseURL includes query parameters", function () { expect(function () { createTriggerChatTransport({