Skip to content

Commit 7fe37c2

Browse files
Cover em-space baseURL wrapper and internal validation
Co-authored-by: Eric Allam <eric@trigger.dev>
1 parent 2ce01e1 commit 7fe37c2

File tree

3 files changed

+48
-0
lines changed

3 files changed

+48
-0
lines changed

docs/tasks/streams.mdx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -676,6 +676,7 @@ Examples:
676676
-`\u2009https://api.trigger.dev/custom-prefix/\u2009` (thin-space wrapper trimmed)
677677
-`\u2008https://api.trigger.dev/custom-prefix/\u2008` (punctuation-space wrapper trimmed)
678678
-`\u2006https://api.trigger.dev/custom-prefix/\u2006` (six-per-em-space wrapper trimmed)
679+
-`\u2003https://api.trigger.dev/custom-prefix/\u2003` (em-space wrapper trimmed)
679680
-`\u205Fhttps://api.trigger.dev/custom-prefix/\u205F` (medium-mathematical-space wrapper trimmed)
680681
-`\u3000https://api.trigger.dev/custom-prefix/\u3000` (ideographic-space wrapper trimmed)
681682
-`\uFEFFhttps://api.trigger.dev/custom-prefix/\uFEFF` (BOM wrapper trimmed)
@@ -713,6 +714,7 @@ Examples:
713714
-`https://api.trigger.dev/\u2009internal`
714715
-`https://api.trigger.dev/\u2008internal`
715716
-`https://api.trigger.dev/\u2006internal`
717+
-`https://api.trigger.dev/\u2003internal`
716718
-`https://api.trigger.dev/\u202Finternal`
717719
-`https://api.trigger.dev/\u205Finternal`
718720
-`https://api.trigger.dev/\u180Einternal`

packages/ai/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ Examples:
183183
-`\u2009https://api.trigger.dev/custom-prefix/\u2009` (thin-space wrapper trimmed)
184184
-`\u2008https://api.trigger.dev/custom-prefix/\u2008` (punctuation-space wrapper trimmed)
185185
-`\u2006https://api.trigger.dev/custom-prefix/\u2006` (six-per-em-space wrapper trimmed)
186+
-`\u2003https://api.trigger.dev/custom-prefix/\u2003` (em-space wrapper trimmed)
186187
-`\u205Fhttps://api.trigger.dev/custom-prefix/\u205F` (medium-mathematical-space wrapper trimmed)
187188
-`\u3000https://api.trigger.dev/custom-prefix/\u3000` (ideographic-space wrapper trimmed)
188189
-`\uFEFFhttps://api.trigger.dev/custom-prefix/\uFEFF` (BOM wrapper trimmed)
@@ -220,6 +221,7 @@ Examples:
220221
-`https://api.trigger.dev/\u2009internal` (internal thin-space characters)
221222
-`https://api.trigger.dev/\u2008internal` (internal punctuation-space characters)
222223
-`https://api.trigger.dev/\u2006internal` (internal six-per-em-space characters)
224+
-`https://api.trigger.dev/\u2003internal` (internal em-space characters)
223225
-`https://api.trigger.dev/\u202Finternal` (internal narrow no-break space characters)
224226
-`https://api.trigger.dev/\u205Finternal` (internal medium-mathematical-space characters)
225227
-`https://api.trigger.dev/\u180Einternal` (internal mongolian-vowel-separator characters)

packages/ai/src/chatTransport.test.ts

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1005,6 +1005,17 @@ describe("TriggerChatTransport", function () {
10051005
}).toThrowError("baseURL must not contain internal whitespace characters");
10061006
});
10071007

1008+
it("throws when baseURL contains internal em-space characters", function () {
1009+
expect(function () {
1010+
new TriggerChatTransport({
1011+
task: "chat-task",
1012+
accessToken: "pk_trigger",
1013+
baseURL: "https://api.trigger.dev/\u2003internal",
1014+
stream: "chat-stream",
1015+
});
1016+
}).toThrowError("baseURL must not contain internal whitespace characters");
1017+
});
1018+
10081019
it("throws when baseURL contains internal mongolian-vowel-separator characters", function () {
10091020
expect(function () {
10101021
new TriggerChatTransport({
@@ -1566,6 +1577,17 @@ describe("TriggerChatTransport", function () {
15661577
}).not.toThrow();
15671578
});
15681579

1580+
it("accepts em-space wrapped baseURL values", function () {
1581+
expect(function () {
1582+
new TriggerChatTransport({
1583+
task: "chat-task",
1584+
accessToken: "pk_trigger",
1585+
baseURL: "\u2003https://api.trigger.dev/custom-prefix/\u2003",
1586+
stream: "chat-stream",
1587+
});
1588+
}).not.toThrow();
1589+
});
1590+
15691591
it("accepts ideographic-space wrapped baseURL values", function () {
15701592
expect(function () {
15711593
new TriggerChatTransport({
@@ -4230,6 +4252,17 @@ describe("TriggerChatTransport", function () {
42304252
}).toThrowError("baseURL must not contain internal whitespace characters");
42314253
});
42324254

4255+
it("throws from factory when baseURL contains internal em-space characters", function () {
4256+
expect(function () {
4257+
createTriggerChatTransport({
4258+
task: "chat-task",
4259+
accessToken: "pk_trigger",
4260+
baseURL: "https://api.trigger.dev/\u2003internal",
4261+
stream: "chat-stream",
4262+
});
4263+
}).toThrowError("baseURL must not contain internal whitespace characters");
4264+
});
4265+
42334266
it("throws from factory when baseURL contains internal mongolian-vowel-separator characters", function () {
42344267
expect(function () {
42354268
createTriggerChatTransport({
@@ -4780,6 +4813,17 @@ describe("TriggerChatTransport", function () {
47804813
}).not.toThrow();
47814814
});
47824815

4816+
it("accepts em-space wrapped baseURL values from factory", function () {
4817+
expect(function () {
4818+
createTriggerChatTransport({
4819+
task: "chat-task",
4820+
accessToken: "pk_trigger",
4821+
baseURL: "\u2003https://api.trigger.dev/custom-prefix/\u2003",
4822+
stream: "chat-stream",
4823+
});
4824+
}).not.toThrow();
4825+
});
4826+
47834827
it("accepts ideographic-space wrapped baseURL values from factory", function () {
47844828
expect(function () {
47854829
createTriggerChatTransport({

0 commit comments

Comments
 (0)