mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Default event type to 'message' if it's empty
Added to the upstream test suite. Matches the spec.
This commit is contained in:
@ -18,7 +18,7 @@ class EventSourceStream {
|
|||||||
streamBuffer = events.pop();
|
streamBuffer = events.pop();
|
||||||
|
|
||||||
for (const eventChunk of events) {
|
for (const eventChunk of events) {
|
||||||
let eventType = 'message';
|
let eventType = '';
|
||||||
// Split up by single newlines.
|
// Split up by single newlines.
|
||||||
const lines = eventChunk.split(/\n|\r|\r\n/g);
|
const lines = eventChunk.split(/\n|\r|\r\n/g);
|
||||||
let eventData = '';
|
let eventData = '';
|
||||||
@ -55,7 +55,7 @@ class EventSourceStream {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Trim the *last* trailing newline only.
|
// 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);
|
controller.enqueue(event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user