Cover newline-tab wrapped websocket protocol validation

Co-authored-by: Eric Allam <eric@trigger.dev>
This commit is contained in:
Cursor Agent
2026-02-15 06:55:05 +00:00
parent 3e7fe1fb29
commit bcd5a3aac7
3 changed files with 46 additions and 0 deletions
+1
View File
@@ -689,6 +689,7 @@ Examples:
- ❌ `\u205F///\u205F` (empty after trimming wrapper whitespace)
- ❌ `\u3000///\u3000` (empty after trimming wrapper whitespace)
- ❌ `\n\thttps://api.trigger.dev/base/?query=1\t\n` (query is still rejected after trimming wrappers)
- ❌ `\n\tws://api.trigger.dev\t\n` / `\n\twss://api.trigger.dev\t\n` (trimmed wrappers still reject websocket protocols)
- ❌ `https://api.trigger.dev/\ninternal`
- ❌ `https://api.trigger.dev/in valid`
- ❌ `https://api.trigger.dev/\tinternal`
+1
View File
@@ -196,6 +196,7 @@ Examples:
-`\u205F///\u205F` (empty after trimming wrapper whitespace)
-`\u3000///\u3000` (empty after trimming wrapper whitespace)
-`\n\thttps://api.trigger.dev/base/?query=1\t\n` (query is still rejected after trimming wrappers)
-`\n\tws://api.trigger.dev\t\n` / `\n\twss://api.trigger.dev\t\n` (trimmed wrappers still reject websocket protocols)
-`https://api.trigger.dev/\ninternal` (internal whitespace characters)
-`https://api.trigger.dev/in valid` (internal space characters)
-`https://api.trigger.dev/\tinternal` (internal tab characters)
+44
View File
@@ -1061,6 +1061,17 @@ describe("TriggerChatTransport", function () {
}).toThrowError("baseURL must use http or https protocol");
});
it("throws when newline-and-tab wrapped baseURL protocol is ws", function () {
expect(function () {
new TriggerChatTransport({
task: "chat-task",
accessToken: "pk_trigger",
baseURL: "\n\tws://example.com\t\n",
stream: "chat-stream",
});
}).toThrowError("baseURL must use http or https protocol");
});
it("throws when baseURL protocol is wss", function () {
expect(function () {
new TriggerChatTransport({
@@ -1083,6 +1094,17 @@ describe("TriggerChatTransport", function () {
}).toThrowError("baseURL must use http or https protocol");
});
it("throws when newline-and-tab wrapped baseURL protocol is wss", function () {
expect(function () {
new TriggerChatTransport({
task: "chat-task",
accessToken: "pk_trigger",
baseURL: "\n\twss://example.com\t\n",
stream: "chat-stream",
});
}).toThrowError("baseURL must use http or https protocol");
});
it("throws when baseURL includes query parameters", function () {
expect(function () {
new TriggerChatTransport({
@@ -4053,6 +4075,17 @@ describe("TriggerChatTransport", function () {
}).toThrowError("baseURL must use http or https protocol");
});
it("throws from factory when newline-and-tab wrapped baseURL protocol is ws", function () {
expect(function () {
createTriggerChatTransport({
task: "chat-task",
accessToken: "pk_trigger",
baseURL: "\n\tws://example.com\t\n",
stream: "chat-stream",
});
}).toThrowError("baseURL must use http or https protocol");
});
it("throws from factory when baseURL protocol is wss", function () {
expect(function () {
createTriggerChatTransport({
@@ -4075,6 +4108,17 @@ describe("TriggerChatTransport", function () {
}).toThrowError("baseURL must use http or https protocol");
});
it("throws from factory when newline-and-tab wrapped baseURL protocol is wss", function () {
expect(function () {
createTriggerChatTransport({
task: "chat-task",
accessToken: "pk_trigger",
baseURL: "\n\twss://example.com\t\n",
stream: "chat-stream",
});
}).toThrowError("baseURL must use http or https protocol");
});
it("throws from factory when baseURL includes query parameters", function () {
expect(function () {
createTriggerChatTransport({