Skip to content

Commit 61adcdd

Browse files
committed
fix: deal with empty answer
1 parent 0062158 commit 61adcdd

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

src/Action.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ export class Action {
4949
appendAnswer(buffer) {
5050
let string = new TextDecoder().decode(buffer);
5151
this.status = STATUS_ANSWER_PARTIALLY_RECEIVED;
52-
this.answer += string;
53-
if (!this.answer.replace(/\r/g, '').endsWith('\n\n')) return;
54-
let lines = this.answer.split(/\r?\n/);
52+
this.answer += string.replace(/\r/g, '');
53+
if (!this.answer.endsWith('\n\n') && this.answer !== '\n') return;
54+
let lines = this.answer.split(/\n/);
5555
if (lines.length > 0 && lines[lines.length - 1] === '') {
5656
lines = lines.filter((line) => line);
5757
this.status = STATUS_ANSWER_RECEIVED;

0 commit comments

Comments
 (0)