fix: normalize line endings for consistent chunk splitting (#235)
This commit is contained in:
parent
4ddd659d8d
commit
eaaad27e44
|
|
@ -103,7 +103,8 @@ async function* chatReplayStream(
|
||||||
const text = await fetchReplay(replayFilePath, {
|
const text = await fetchReplay(replayFilePath, {
|
||||||
abortSignal: options.abortSignal,
|
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) {
|
for (const chunk of chunks) {
|
||||||
const [eventRaw, dataRaw] = chunk.split("\n") as [string, string];
|
const [eventRaw, dataRaw] = chunk.split("\n") as [string, string];
|
||||||
const [, event] = eventRaw.split("event: ", 2) as [string, string];
|
const [, event] = eventRaw.split("event: ", 2) as [string, string];
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue