diff options
author | ud2 <sjx233@qq.com> | 2024-03-25 22:31:13 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-25 07:31:13 -0700 |
commit | 5c1fa0cf9cbe4301082b6cad343d42ef4c414c0d (patch) | |
tree | fb0b360146bf9bc59c7987e965dec3c7ee177f6a /ext/fetch/27_eventsource.js | |
parent | bf9c57aeac7c9d03a382cc7bfb54cc41ddaf1f27 (diff) |
fix(ext/fetch): do not truncate field value in `EventSource` (#22368)
Depends on #22493. Closes #22367.
Diffstat (limited to 'ext/fetch/27_eventsource.js')
-rw-r--r-- | ext/fetch/27_eventsource.js | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/ext/fetch/27_eventsource.js b/ext/fetch/27_eventsource.js index 02b77e88d..1ab9d8009 100644 --- a/ext/fetch/27_eventsource.js +++ b/ext/fetch/27_eventsource.js @@ -15,7 +15,6 @@ const { StringPrototypeIncludes, StringPrototypeIndexOf, StringPrototypeSlice, - StringPrototypeSplit, StringPrototypeStartsWith, StringPrototypeToLowerCase, SymbolFor, @@ -268,8 +267,10 @@ class EventSource extends EventTarget { } else { let field = chunk; let value = ""; - if (StringPrototypeIncludes(chunk, ":")) { - ({ 0: field, 1: value } = StringPrototypeSplit(chunk, ":")); + const colonIndex = StringPrototypeIndexOf(chunk, ":"); + if (colonIndex !== -1) { + field = StringPrototypeSlice(chunk, 0, colonIndex); + value = StringPrototypeSlice(chunk, colonIndex + 1); if (StringPrototypeStartsWith(value, " ")) { value = StringPrototypeSlice(value, 1); } |