msw 0.36.4 → 0.38.0
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/README.md +3 -1
- package/lib/esm/RequestHandler-deps.js +5 -6
- package/lib/esm/fetch-deps.js +14 -12
- package/lib/esm/graphql-deps.js +1980 -1804
- package/lib/esm/index.js +59 -44
- package/lib/esm/mockServiceWorker.js +1 -1
- package/lib/iife/index.js +3 -3
- package/lib/iife/mockServiceWorker.js +1 -1
- package/lib/types/graphql.d.ts +6 -6
- package/lib/types/handlers/RequestHandler.d.ts +2 -2
- package/lib/types/response.d.ts +1 -1
- package/lib/types/setupWorker/glossary.d.ts +1 -1
- package/lib/types/utils/logging/prepareResponse.d.ts +2 -2
- package/lib/types/utils/request/onUnhandledRequest.d.ts +5 -1
- package/lib/types/utils/request/parseBody.d.ts +1 -1
- package/lib/umd/index.js +17427 -14532
- package/lib/umd/mockServiceWorker.js +1 -1
- package/native/lib/index.js +2030 -1838
- package/node/lib/index.js +2030 -1838
- package/package.json +34 -26
package/README.md
CHANGED
|
@@ -136,11 +136,9 @@ var InvariantError = /** @class */ (function (_super) {
|
|
|
136
136
|
_this.name = 'Invariant Violation';
|
|
137
137
|
_this.message = format_1.format.apply(void 0, __spreadArray([message], positionals));
|
|
138
138
|
if (_this.stack) {
|
|
139
|
-
var
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
.slice(STACK_FRAMES_TO_IGNORE)
|
|
143
|
-
.join('\n');
|
|
139
|
+
var nextStack = _this.stack.split('\n');
|
|
140
|
+
nextStack.splice(1, STACK_FRAMES_TO_IGNORE);
|
|
141
|
+
_this.stack = nextStack.join('\n');
|
|
144
142
|
}
|
|
145
143
|
return _this;
|
|
146
144
|
}
|
|
@@ -283,11 +281,12 @@ function parseMultipartData(data, headers) {
|
|
|
283
281
|
* Parses a given request/response body based on the "Content-Type" header.
|
|
284
282
|
*/
|
|
285
283
|
function parseBody(body, headers) {
|
|
284
|
+
var _a;
|
|
286
285
|
// Return whatever falsey body value is given.
|
|
287
286
|
if (!body) {
|
|
288
287
|
return body;
|
|
289
288
|
}
|
|
290
|
-
const contentType = (headers === null || headers === void 0 ? void 0 : headers.get('content-type')) || '';
|
|
289
|
+
const contentType = ((_a = headers === null || headers === void 0 ? void 0 : headers.get('content-type')) === null || _a === void 0 ? void 0 : _a.toLowerCase()) || '';
|
|
291
290
|
// If the body has a Multipart Content-Type
|
|
292
291
|
// parse it into an object.
|
|
293
292
|
const hasMultipartContent = contentType.startsWith('multipart/form-data');
|
package/lib/esm/fetch-deps.js
CHANGED
|
@@ -656,7 +656,6 @@ var serialize_1 = serialize;
|
|
|
656
656
|
|
|
657
657
|
var decode = decodeURIComponent;
|
|
658
658
|
var encode = encodeURIComponent;
|
|
659
|
-
var pairSplitRegExp = /; */;
|
|
660
659
|
|
|
661
660
|
/**
|
|
662
661
|
* RegExp to match field-content in RFC 7230 sec 3.2
|
|
@@ -687,28 +686,29 @@ function parse(str, options) {
|
|
|
687
686
|
|
|
688
687
|
var obj = {};
|
|
689
688
|
var opt = options || {};
|
|
690
|
-
var pairs = str.split(
|
|
689
|
+
var pairs = str.split(';');
|
|
691
690
|
var dec = opt.decode || decode;
|
|
692
691
|
|
|
693
692
|
for (var i = 0; i < pairs.length; i++) {
|
|
694
693
|
var pair = pairs[i];
|
|
695
|
-
var
|
|
694
|
+
var index = pair.indexOf('=');
|
|
696
695
|
|
|
697
696
|
// skip things that don't look like key=value
|
|
698
|
-
if (
|
|
697
|
+
if (index < 0) {
|
|
699
698
|
continue;
|
|
700
699
|
}
|
|
701
700
|
|
|
702
|
-
var key = pair.
|
|
703
|
-
var val = pair.substr(++eq_idx, pair.length).trim();
|
|
704
|
-
|
|
705
|
-
// quoted values
|
|
706
|
-
if ('"' == val[0]) {
|
|
707
|
-
val = val.slice(1, -1);
|
|
708
|
-
}
|
|
701
|
+
var key = pair.substring(0, index).trim();
|
|
709
702
|
|
|
710
703
|
// only assign once
|
|
711
704
|
if (undefined == obj[key]) {
|
|
705
|
+
var val = pair.substring(index + 1, pair.length).trim();
|
|
706
|
+
|
|
707
|
+
// quoted values
|
|
708
|
+
if (val[0] === '"') {
|
|
709
|
+
val = val.slice(1, -1);
|
|
710
|
+
}
|
|
711
|
+
|
|
712
712
|
obj[key] = tryDecode(val, dec);
|
|
713
713
|
}
|
|
714
714
|
}
|
|
@@ -974,7 +974,9 @@ const createFetchRequestParameters = (input) => {
|
|
|
974
974
|
if (['GET', 'HEAD'].includes(method)) {
|
|
975
975
|
return requestParameters;
|
|
976
976
|
}
|
|
977
|
-
if (typeof body === 'object' ||
|
|
977
|
+
if (typeof body === 'object' ||
|
|
978
|
+
typeof body === 'number' ||
|
|
979
|
+
typeof body === 'boolean') {
|
|
978
980
|
requestParameters.body = JSON.stringify(body);
|
|
979
981
|
}
|
|
980
982
|
else {
|