msw 2.6.6 → 2.6.7
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.
- package/lib/browser/index.js +9 -9
- package/lib/browser/index.js.map +1 -1
- package/lib/browser/index.mjs +9 -9
- package/lib/browser/index.mjs.map +1 -1
- package/lib/iife/index.js +306 -501
- package/lib/iife/index.js.map +1 -1
- package/lib/mockServiceWorker.js +15 -3
- package/package.json +3 -4
- package/src/mockServiceWorker.js +13 -1
package/lib/mockServiceWorker.js
CHANGED
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
* - Please do NOT serve this file on production.
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
const PACKAGE_VERSION = '2.6.
|
|
12
|
-
const INTEGRITY_CHECKSUM = '
|
|
11
|
+
const PACKAGE_VERSION = '2.6.7'
|
|
12
|
+
const INTEGRITY_CHECKSUM = '00729d72e3b82faf54ca8b9621dbb96f'
|
|
13
13
|
const IS_MOCKED_RESPONSE = Symbol('isMockedResponse')
|
|
14
14
|
const activeClientIds = new Set()
|
|
15
15
|
|
|
@@ -199,7 +199,19 @@ async function getResponse(event, client, requestId) {
|
|
|
199
199
|
// Remove the "accept" header value that marked this request as passthrough.
|
|
200
200
|
// This prevents request alteration and also keeps it compliant with the
|
|
201
201
|
// user-defined CORS policies.
|
|
202
|
-
headers.
|
|
202
|
+
const acceptHeader = headers.get('accept')
|
|
203
|
+
if (acceptHeader) {
|
|
204
|
+
const values = acceptHeader.split(',').map((value) => value.trim())
|
|
205
|
+
const filteredValues = values.filter(
|
|
206
|
+
(value) => value !== 'msw/passthrough',
|
|
207
|
+
)
|
|
208
|
+
|
|
209
|
+
if (filteredValues.length > 0) {
|
|
210
|
+
headers.set('accept', filteredValues.join(', '))
|
|
211
|
+
} else {
|
|
212
|
+
headers.delete('accept')
|
|
213
|
+
}
|
|
214
|
+
}
|
|
203
215
|
|
|
204
216
|
return fetch(requestClone, { headers })
|
|
205
217
|
}
|
package/package.json
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "msw",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.7",
|
|
4
4
|
"description": "Seamless REST/GraphQL API mocking library for browser and Node.js.",
|
|
5
5
|
"main": "./lib/core/index.js",
|
|
6
6
|
"module": "./lib/core/index.mjs",
|
|
7
7
|
"types": "./lib/core/index.d.ts",
|
|
8
|
-
"packageManager": "pnpm@8.15.6",
|
|
9
8
|
"exports": {
|
|
10
9
|
".": {
|
|
11
10
|
"types": "./lib/core/index.d.ts",
|
|
@@ -173,7 +172,7 @@
|
|
|
173
172
|
"json-bigint": "^1.0.0",
|
|
174
173
|
"lint-staged": "^15.2.10",
|
|
175
174
|
"page-with": "^0.6.1",
|
|
176
|
-
"prettier": "^3.
|
|
175
|
+
"prettier": "^3.4.2",
|
|
177
176
|
"regenerator-runtime": "^0.14.1",
|
|
178
177
|
"rimraf": "^6.0.1",
|
|
179
178
|
"simple-git-hooks": "^2.9.0",
|
|
@@ -182,7 +181,7 @@
|
|
|
182
181
|
"typescript": "^5.5.2",
|
|
183
182
|
"undici": "^6.20.0",
|
|
184
183
|
"url-loader": "^4.1.1",
|
|
185
|
-
"vitest": "^1.
|
|
184
|
+
"vitest": "^2.1.8",
|
|
186
185
|
"vitest-environment-miniflare": "^2.14.4",
|
|
187
186
|
"webpack": "^5.95.0",
|
|
188
187
|
"webpack-http-server": "^0.5.0"
|
package/src/mockServiceWorker.js
CHANGED
|
@@ -199,7 +199,19 @@ async function getResponse(event, client, requestId) {
|
|
|
199
199
|
// Remove the "accept" header value that marked this request as passthrough.
|
|
200
200
|
// This prevents request alteration and also keeps it compliant with the
|
|
201
201
|
// user-defined CORS policies.
|
|
202
|
-
headers.
|
|
202
|
+
const acceptHeader = headers.get('accept')
|
|
203
|
+
if (acceptHeader) {
|
|
204
|
+
const values = acceptHeader.split(',').map((value) => value.trim())
|
|
205
|
+
const filteredValues = values.filter(
|
|
206
|
+
(value) => value !== 'msw/passthrough',
|
|
207
|
+
)
|
|
208
|
+
|
|
209
|
+
if (filteredValues.length > 0) {
|
|
210
|
+
headers.set('accept', filteredValues.join(', '))
|
|
211
|
+
} else {
|
|
212
|
+
headers.delete('accept')
|
|
213
|
+
}
|
|
214
|
+
}
|
|
203
215
|
|
|
204
216
|
return fetch(requestClone, { headers })
|
|
205
217
|
}
|