From 78b5f5cd4fb1a221802a00adc6899781700ee4e1 Mon Sep 17 00:00:00 2001 From: Thomas Kreis Date: Fri, 25 Jul 2025 20:44:23 +0200 Subject: [PATCH] fix: remove greedy removal of whitespace the space states it should only remove U+0020 not all whitespace https://html.spec.whatwg.org/multipage/server-sent-events.html#parsing-an-event-stream --- src/EventSource.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/EventSource.js b/src/EventSource.js index 8b2991d..650be82 100644 --- a/src/EventSource.js +++ b/src/EventSource.js @@ -228,7 +228,7 @@ class EventSource { this.interval = retry; } } else if (line.startsWith('data')) { - data.push(line.replace(/data:?\s*/, '')); + data.push(line.replace(/^data: ?/, '')); } else if (line.startsWith('id')) { id = line.replace(/id:?\s*/, ''); if (id !== '') {