Skip to content

Commit cb701f2

Browse files
Cover trimmed hash and credential baseURL rejection
Co-authored-by: Eric Allam <eric@trigger.dev>
1 parent 861e42a commit cb701f2

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
@@ -686,6 +686,17 @@ describe("TriggerChatTransport", function () {
686686
}).toThrowError("baseURL must not include query parameters or hash fragments");
687687
});
688688

689+
it("throws when trimmed baseURL includes hash fragments", function () {
690+
expect(function () {
691+
new TriggerChatTransport({
692+
task: "chat-task",
693+
accessToken: "pk_trigger",
694+
baseURL: " https://example.com/base/#fragment ",
695+
stream: "chat-stream",
696+
});
697+
}).toThrowError("baseURL must not include query parameters or hash fragments");
698+
});
699+
689700
it("throws when baseURL includes username or password credentials", function () {
690701
expect(function () {
691702
new TriggerChatTransport({
@@ -697,6 +708,17 @@ describe("TriggerChatTransport", function () {
697708
}).toThrowError("baseURL must not include username or password credentials");
698709
});
699710

711+
it("throws when trimmed baseURL includes username or password credentials", function () {
712+
expect(function () {
713+
new TriggerChatTransport({
714+
task: "chat-task",
715+
accessToken: "pk_trigger",
716+
baseURL: " https://user:pass@example.com/base/ ",
717+
stream: "chat-stream",
718+
});
719+
}).toThrowError("baseURL must not include username or password credentials");
720+
});
721+
700722
it("accepts https baseURL values without throwing", function () {
701723
expect(function () {
702724
new TriggerChatTransport({
@@ -2958,6 +2980,17 @@ describe("TriggerChatTransport", function () {
29582980
}).toThrowError("baseURL must not include query parameters or hash fragments");
29592981
});
29602982

2983+
it("throws from factory when trimmed baseURL includes hash fragments", function () {
2984+
expect(function () {
2985+
createTriggerChatTransport({
2986+
task: "chat-task",
2987+
accessToken: "pk_trigger",
2988+
baseURL: " https://example.com/base/#fragment ",
2989+
stream: "chat-stream",
2990+
});
2991+
}).toThrowError("baseURL must not include query parameters or hash fragments");
2992+
});
2993+
29612994
it("throws from factory when baseURL includes username or password credentials", function () {
29622995
expect(function () {
29632996
createTriggerChatTransport({
@@ -2969,6 +3002,17 @@ describe("TriggerChatTransport", function () {
29693002
}).toThrowError("baseURL must not include username or password credentials");
29703003
});
29713004

3005+
it("throws from factory when trimmed baseURL includes username or password credentials", function () {
3006+
expect(function () {
3007+
createTriggerChatTransport({
3008+
task: "chat-task",
3009+
accessToken: "pk_trigger",
3010+
baseURL: " https://user:pass@example.com/base/ ",
3011+
stream: "chat-stream",
3012+
});
3013+
}).toThrowError("baseURL must not include username or password credentials");
3014+
});
3015+
29723016
it("accepts https baseURL values from factory without throwing", function () {
29733017
expect(function () {
29743018
createTriggerChatTransport({

0 commit comments

Comments
 (0)