From eaaad27e444e66d8cc2d7167e8935a806f0a59f7 Mon Sep 17 00:00:00 2001 From: Aeolusw <32787759+Aeolusw@users.noreply.github.com> Date: Thu, 29 May 2025 20:46:57 +0800 Subject: [PATCH] fix: normalize line endings for consistent chunk splitting (#235) --- web/src/core/api/chat.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/web/src/core/api/chat.ts b/web/src/core/api/chat.ts index b1b92f5..437477b 100644 --- a/web/src/core/api/chat.ts +++ b/web/src/core/api/chat.ts @@ -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];