Default event type to 'message' if it's empty

Added to the upstream test suite. Matches the spec.
This commit is contained in:
valadaptive 2023-12-10 04:43:12 -05:00
parent 3cfc32c16d
commit 0201a0260c
1 changed files with 2 additions and 2 deletions

View File

@ -18,7 +18,7 @@ class EventSourceStream {
streamBuffer = events.pop();
for (const eventChunk of events) {
let eventType = 'message';
let eventType = '';
// Split up by single newlines.
const lines = eventChunk.split(/\n|\r|\r\n/g);
let eventData = '';
@ -55,7 +55,7 @@ class EventSourceStream {
}
// Trim the *last* trailing newline only.
const event = new MessageEvent(eventType, { data: eventData, lastEventId });
const event = new MessageEvent(eventType || 'message', { data: eventData, lastEventId });
controller.enqueue(event);
}
}