Skip to content

Commit 341e345

Browse files
Cover trimmed ws and wss baseURL rejection
Co-authored-by: Eric Allam <eric@trigger.dev>
1 parent 5a017a7 commit 341e345

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

packages/ai/src/chatTransport.test.ts

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -664,6 +664,17 @@ describe("TriggerChatTransport", function () {
664664
}).toThrowError("baseURL must use http or https protocol");
665665
});
666666

667+
it("throws when trimmed baseURL protocol is ws", function () {
668+
expect(function () {
669+
new TriggerChatTransport({
670+
task: "chat-task",
671+
accessToken: "pk_trigger",
672+
baseURL: " ws://example.com ",
673+
stream: "chat-stream",
674+
});
675+
}).toThrowError("baseURL must use http or https protocol");
676+
});
677+
667678
it("throws when baseURL protocol is wss", function () {
668679
expect(function () {
669680
new TriggerChatTransport({
@@ -675,6 +686,17 @@ describe("TriggerChatTransport", function () {
675686
}).toThrowError("baseURL must use http or https protocol");
676687
});
677688

689+
it("throws when trimmed baseURL protocol is wss", function () {
690+
expect(function () {
691+
new TriggerChatTransport({
692+
task: "chat-task",
693+
accessToken: "pk_trigger",
694+
baseURL: " wss://example.com ",
695+
stream: "chat-stream",
696+
});
697+
}).toThrowError("baseURL must use http or https protocol");
698+
});
699+
678700
it("throws when baseURL includes query parameters", function () {
679701
expect(function () {
680702
new TriggerChatTransport({
@@ -2991,6 +3013,17 @@ describe("TriggerChatTransport", function () {
29913013
}).toThrowError("baseURL must use http or https protocol");
29923014
});
29933015

3016+
it("throws from factory when trimmed baseURL protocol is ws", function () {
3017+
expect(function () {
3018+
createTriggerChatTransport({
3019+
task: "chat-task",
3020+
accessToken: "pk_trigger",
3021+
baseURL: " ws://example.com ",
3022+
stream: "chat-stream",
3023+
});
3024+
}).toThrowError("baseURL must use http or https protocol");
3025+
});
3026+
29943027
it("throws from factory when baseURL protocol is wss", function () {
29953028
expect(function () {
29963029
createTriggerChatTransport({
@@ -3002,6 +3035,17 @@ describe("TriggerChatTransport", function () {
30023035
}).toThrowError("baseURL must use http or https protocol");
30033036
});
30043037

3038+
it("throws from factory when trimmed baseURL protocol is wss", function () {
3039+
expect(function () {
3040+
createTriggerChatTransport({
3041+
task: "chat-task",
3042+
accessToken: "pk_trigger",
3043+
baseURL: " wss://example.com ",
3044+
stream: "chat-stream",
3045+
});
3046+
}).toThrowError("baseURL must use http or https protocol");
3047+
});
3048+
30053049
it("throws from factory when baseURL includes query parameters", function () {
30063050
expect(function () {
30073051
createTriggerChatTransport({

0 commit comments

Comments
 (0)