Cover uppercase HTTP baseURL protocol handling

Co-authored-by: Eric Allam <eric@trigger.dev>
This commit is contained in:
Cursor Agent
2026-02-15 04:24:49 +00:00
parent 9afa035574
commit 915573cfd0
+70
View File
@@ -653,6 +653,76 @@ describe("TriggerChatTransport", function () {
}).toThrowError("baseURL must use http or https protocol");
});
it("accepts uppercase http protocol in baseURL", async function () {
let observedTriggerPath: string | undefined;
let observedStreamPath: string | undefined;
const server = await startServer(function (req, res) {
if (req.method === "POST") {
observedTriggerPath = req.url ?? "";
}
if (req.method === "GET") {
observedStreamPath = req.url ?? "";
}
if (req.method === "POST" && req.url === "/api/v1/tasks/chat-task/trigger") {
res.writeHead(200, {
"content-type": "application/json",
"x-trigger-jwt": "pk_run_uppercase_protocol",
});
res.end(JSON.stringify({ id: "run_uppercase_protocol" }));
return;
}
if (
req.method === "GET" &&
req.url === "/realtime/v1/streams/run_uppercase_protocol/chat-stream"
) {
res.writeHead(200, {
"content-type": "text/event-stream",
});
writeSSE(
res,
"1-0",
JSON.stringify({ type: "text-start", id: "uppercase_protocol_1" })
);
writeSSE(
res,
"2-0",
JSON.stringify({ type: "text-end", id: "uppercase_protocol_1" })
);
res.end();
return;
}
res.writeHead(404);
res.end();
});
const uppercasedProtocolBaseUrl = server.url.replace(/^http:\/\//, "HTTP://");
const transport = new TriggerChatTransport({
task: "chat-task",
accessToken: "pk_trigger",
baseURL: uppercasedProtocolBaseUrl,
stream: "chat-stream",
});
const stream = await transport.sendMessages({
trigger: "submit-message",
chatId: "chat-uppercase-protocol",
messageId: undefined,
messages: [],
abortSignal: undefined,
});
const chunks = await readChunks(stream);
expect(chunks).toHaveLength(2);
expect(observedTriggerPath).toBe("/api/v1/tasks/chat-task/trigger");
expect(observedStreamPath).toBe("/realtime/v1/streams/run_uppercase_protocol/chat-stream");
});
it("combines path prefixes with run and stream URL encoding", async function () {
let observedTriggerPath: string | undefined;
let observedStreamPath: string | undefined;