Skip to content

Commit a3dbae6

Browse files
Cover thin-space baseURL wrapper and internal validation
Co-authored-by: Eric Allam <eric@trigger.dev>
1 parent 7caa78f commit a3dbae6

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
@@ -673,6 +673,7 @@ Examples:
673673
-`\u1680https://api.trigger.dev/custom-prefix/\u1680` (ogham-space-mark wrapper trimmed)
674674
-`\u2007https://api.trigger.dev/custom-prefix/\u2007` (figure-space wrapper trimmed)
675675
-`\u200Ahttps://api.trigger.dev/custom-prefix/\u200A` (hair-space wrapper trimmed)
676+
-`\u2009https://api.trigger.dev/custom-prefix/\u2009` (thin-space wrapper trimmed)
676677
-`\u205Fhttps://api.trigger.dev/custom-prefix/\u205F` (medium-mathematical-space wrapper trimmed)
677678
-`\u3000https://api.trigger.dev/custom-prefix/\u3000` (ideographic-space wrapper trimmed)
678679
-`\uFEFFhttps://api.trigger.dev/custom-prefix/\uFEFF` (BOM wrapper trimmed)
@@ -707,6 +708,7 @@ Examples:
707708
-`https://api.trigger.dev/\u1680internal`
708709
-`https://api.trigger.dev/\u2007internal`
709710
-`https://api.trigger.dev/\u200Ainternal`
711+
-`https://api.trigger.dev/\u2009internal`
710712
-`https://api.trigger.dev/\u202Finternal`
711713
-`https://api.trigger.dev/\u205Finternal`
712714
-`https://api.trigger.dev/\u180Einternal`

packages/ai/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ Examples:
180180
-`\u1680https://api.trigger.dev/custom-prefix/\u1680` (ogham-space-mark wrapper trimmed)
181181
-`\u2007https://api.trigger.dev/custom-prefix/\u2007` (figure-space wrapper trimmed)
182182
-`\u200Ahttps://api.trigger.dev/custom-prefix/\u200A` (hair-space wrapper trimmed)
183+
-`\u2009https://api.trigger.dev/custom-prefix/\u2009` (thin-space wrapper trimmed)
183184
-`\u205Fhttps://api.trigger.dev/custom-prefix/\u205F` (medium-mathematical-space wrapper trimmed)
184185
-`\u3000https://api.trigger.dev/custom-prefix/\u3000` (ideographic-space wrapper trimmed)
185186
-`\uFEFFhttps://api.trigger.dev/custom-prefix/\uFEFF` (BOM wrapper trimmed)
@@ -214,6 +215,7 @@ Examples:
214215
-`https://api.trigger.dev/\u1680internal` (internal ogham-space-mark characters)
215216
-`https://api.trigger.dev/\u2007internal` (internal figure-space characters)
216217
-`https://api.trigger.dev/\u200Ainternal` (internal hair-space characters)
218+
-`https://api.trigger.dev/\u2009internal` (internal thin-space characters)
217219
-`https://api.trigger.dev/\u202Finternal` (internal narrow no-break space characters)
218220
-`https://api.trigger.dev/\u205Finternal` (internal medium-mathematical-space characters)
219221
-`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
@@ -972,6 +972,17 @@ describe("TriggerChatTransport", function () {
972972
}).toThrowError("baseURL must not contain internal whitespace characters");
973973
});
974974

975+
it("throws when baseURL contains internal thin-space characters", function () {
976+
expect(function () {
977+
new TriggerChatTransport({
978+
task: "chat-task",
979+
accessToken: "pk_trigger",
980+
baseURL: "https://api.trigger.dev/\u2009internal",
981+
stream: "chat-stream",
982+
});
983+
}).toThrowError("baseURL must not contain internal whitespace characters");
984+
});
985+
975986
it("throws when baseURL contains internal mongolian-vowel-separator characters", function () {
976987
expect(function () {
977988
new TriggerChatTransport({
@@ -1500,6 +1511,17 @@ describe("TriggerChatTransport", function () {
15001511
}).not.toThrow();
15011512
});
15021513

1514+
it("accepts thin-space wrapped baseURL values", function () {
1515+
expect(function () {
1516+
new TriggerChatTransport({
1517+
task: "chat-task",
1518+
accessToken: "pk_trigger",
1519+
baseURL: "\u2009https://api.trigger.dev/custom-prefix/\u2009",
1520+
stream: "chat-stream",
1521+
});
1522+
}).not.toThrow();
1523+
});
1524+
15031525
it("accepts ideographic-space wrapped baseURL values", function () {
15041526
expect(function () {
15051527
new TriggerChatTransport({
@@ -4131,6 +4153,17 @@ describe("TriggerChatTransport", function () {
41314153
}).toThrowError("baseURL must not contain internal whitespace characters");
41324154
});
41334155

4156+
it("throws from factory when baseURL contains internal thin-space characters", function () {
4157+
expect(function () {
4158+
createTriggerChatTransport({
4159+
task: "chat-task",
4160+
accessToken: "pk_trigger",
4161+
baseURL: "https://api.trigger.dev/\u2009internal",
4162+
stream: "chat-stream",
4163+
});
4164+
}).toThrowError("baseURL must not contain internal whitespace characters");
4165+
});
4166+
41344167
it("throws from factory when baseURL contains internal mongolian-vowel-separator characters", function () {
41354168
expect(function () {
41364169
createTriggerChatTransport({
@@ -4648,6 +4681,17 @@ describe("TriggerChatTransport", function () {
46484681
}).not.toThrow();
46494682
});
46504683

4684+
it("accepts thin-space wrapped baseURL values from factory", function () {
4685+
expect(function () {
4686+
createTriggerChatTransport({
4687+
task: "chat-task",
4688+
accessToken: "pk_trigger",
4689+
baseURL: "\u2009https://api.trigger.dev/custom-prefix/\u2009",
4690+
stream: "chat-stream",
4691+
});
4692+
}).not.toThrow();
4693+
});
4694+
46514695
it("accepts ideographic-space wrapped baseURL values from factory", function () {
46524696
expect(function () {
46534697
createTriggerChatTransport({

0 commit comments

Comments
 (0)