fix: normalize line endings for consistent chunk splitting (#235)

This commit is contained in:
Aeolusw 2025-05-29 20:46:57 +08:00 committed by GitHub
parent 4ddd659d8d
commit eaaad27e44
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -103,7 +103,8 @@ async function* chatReplayStream(
const text = await fetchReplay(replayFilePath, {
abortSignal: options.abortSignal,
});
const chunks = text.split("\n\n");
const normalizedText = text.replace(/\r\n/g, "\n");
const chunks = normalizedText.split("\n\n");
for (const chunk of chunks) {
const [eventRaw, dataRaw] = chunk.split("\n") as [string, string];
const [, event] = eventRaw.split("event: ", 2) as [string, string];