msw 2.12.4 → 2.12.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,7 +7,7 @@
7
7
  * - Please do NOT modify this file.
8
8
  */
9
9
 
10
- const PACKAGE_VERSION = '2.12.4'
10
+ const PACKAGE_VERSION = '2.12.5'
11
11
  const INTEGRITY_CHECKSUM = '4db4a41e972cec1b64cc569c66952d82'
12
12
  const IS_MOCKED_RESPONSE = Symbol('isMockedResponse')
13
13
  const activeClientIds = new Set()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "msw",
3
- "version": "2.12.4",
3
+ "version": "2.12.5",
4
4
  "description": "Seamless REST/GraphQL API mocking library for browser and Node.js.",
5
5
  "type": "commonjs",
6
6
  "main": "./lib/core/index.js",
@@ -285,7 +285,7 @@
285
285
  "vitest-environment-miniflare": "^2.14.4",
286
286
  "webpack": "^5.95.0",
287
287
  "webpack-http-server": "^0.5.0",
288
- "msw": "2.12.4"
288
+ "msw": "2.12.5"
289
289
  },
290
290
  "peerDependencies": {
291
291
  "typescript": ">= 4.8.x"
package/src/core/sse.ts CHANGED
@@ -327,7 +327,17 @@ class ServerSentEventClient<
327
327
  frames.push(`event:${message.event?.toString()}`)
328
328
  }
329
329
 
330
- frames.push(`data:${message.data}`)
330
+ if (message.data != null) {
331
+ /**
332
+ * Split data on line terminators (LF, CR, or CRLF) and translate them to individual frames.
333
+ * @see https://html.spec.whatwg.org/multipage/server-sent-events.html#event-stream-interpretation
334
+ * @see https://html.spec.whatwg.org/multipage/server-sent-events.html#parsing-an-event-stream
335
+ */
336
+ for (const line of message.data.toString().split(/\r\n|\r|\n/)) {
337
+ frames.push(`data:${line}`)
338
+ }
339
+ }
340
+
331
341
  frames.push('', '')
332
342
 
333
343
  this.#controller.enqueue(this.#encoder.encode(frames.join('\n')))