Skip to content

Commit a7dd637

Browse files
committed
fix: Don't require a space after data: when processing SSE events
1 parent 76914c2 commit a7dd637

File tree

1 file changed

+7
-4
lines changed
  • sdks/typescript/packages/client/src/transform

1 file changed

+7
-4
lines changed

sdks/typescript/packages/client/src/transform/sse.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,17 +52,20 @@ export const parseSSEStream = (source$: Observable<HttpEvent>): Observable<any>
5252
/**
5353
* Helper function to process an SSE event.
5454
* Extracts and joins data lines, then parses the result as JSON.
55-
* Follows the SSE spec by only processing 'data:' prefixed lines.
55+
*
56+
* Follows the SSE spec by processing lines starting with 'data:',
57+
* ignoring a single space if it is present after the colon.
58+
*
5659
* @param eventText The raw event text to process
5760
*/
5861
function processSSEEvent(eventText: string) {
5962
const lines = eventText.split("\n");
6063
const dataLines: string[] = [];
6164

6265
for (const line of lines) {
63-
if (line.startsWith("data: ")) {
64-
// Extract data content (remove 'data: ' prefix)
65-
dataLines.push(line.slice(6));
66+
if (line.startsWith("data:")) {
67+
// Remove 'data:' prefix, and optionally a single space afterwards
68+
dataLines.push(line.slice(5).replace(/^ /, ""));
6669
}
6770
}
6871

0 commit comments

Comments
 (0)