msw 0.36.3 → 0.36.8

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.
@@ -2,7 +2,7 @@
2
2
  /* tslint:disable */
3
3
 
4
4
  /**
5
- * Mock Service Worker (0.36.3).
5
+ * Mock Service Worker (0.36.8).
6
6
  * @see https://github.com/mswjs/msw
7
7
  * - Please do NOT modify this file.
8
8
  * - Please do NOT serve this file on production.
@@ -977,11 +977,12 @@ function parseMultipartData(data, headers) {
977
977
  * Parses a given request/response body based on the "Content-Type" header.
978
978
  */
979
979
  function parseBody(body, headers) {
980
+ var _a;
980
981
  // Return whatever falsey body value is given.
981
982
  if (!body) {
982
983
  return body;
983
984
  }
984
- const contentType = (headers === null || headers === void 0 ? void 0 : headers.get('content-type')) || '';
985
+ const contentType = ((_a = headers === null || headers === void 0 ? void 0 : headers.get('content-type')) === null || _a === void 0 ? void 0 : _a.toLowerCase()) || '';
985
986
  // If the body has a Multipart Content-Type
986
987
  // parse it into an object.
987
988
  const hasMultipartContent = contentType.startsWith('multipart/form-data');
@@ -1224,11 +1225,9 @@ var InvariantError = /** @class */ (function (_super) {
1224
1225
  _this.name = 'Invariant Violation';
1225
1226
  _this.message = format_1.format.apply(void 0, __spreadArray([message], positionals));
1226
1227
  if (_this.stack) {
1227
- var prevStack = _this.stack;
1228
- _this.stack = prevStack
1229
- .split('\n')
1230
- .slice(STACK_FRAMES_TO_IGNORE)
1231
- .join('\n');
1228
+ var nextStack = _this.stack.split('\n');
1229
+ nextStack.splice(1, STACK_FRAMES_TO_IGNORE);
1230
+ _this.stack = nextStack.join('\n');
1232
1231
  }
1233
1232
  return _this;
1234
1233
  }
@@ -4932,7 +4931,9 @@ const createFetchRequestParameters = (input) => {
4932
4931
  if (['GET', 'HEAD'].includes(method)) {
4933
4932
  return requestParameters;
4934
4933
  }
4935
- if (typeof body === 'object' || typeof body === 'number') {
4934
+ if (typeof body === 'object' ||
4935
+ typeof body === 'number' ||
4936
+ typeof body === 'boolean') {
4936
4937
  requestParameters.body = JSON.stringify(body);
4937
4938
  }
4938
4939
  else {
@@ -5377,12 +5378,23 @@ function cleanUrl(path) {
5377
5378
  return path.replace(REDUNDANT_CHARACTERS_EXP, '');
5378
5379
  }
5379
5380
 
5381
+ /**
5382
+ * Determines if the given URL string is an absolute URL.
5383
+ */
5384
+ function isAbsoluteUrl(url) {
5385
+ return /^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(url);
5386
+ }
5387
+
5380
5388
  /**
5381
5389
  * Returns an absolute URL based on the given path.
5382
5390
  */
5383
5391
  function getAbsoluteUrl(path, baseUrl) {
5384
- // Ignore absolute URLs.
5385
- if (!path.startsWith('/')) {
5392
+ // already absolute URL
5393
+ if (isAbsoluteUrl(path)) {
5394
+ return path;
5395
+ }
5396
+ // Ignore path with pattern start with *
5397
+ if (path.startsWith('*')) {
5386
5398
  return path;
5387
5399
  }
5388
5400
  // Resolve a relative request URL against a given custom "baseUrl"
@@ -5430,12 +5442,17 @@ function coercePath(path) {
5430
5442
  ? `${parameterName}${wildcard}`
5431
5443
  : `${parameterName}${expression}`;
5432
5444
  })
5445
+ /**
5446
+ * Escape the port so that "path-to-regexp" can match
5447
+ * absolute URLs including port numbers.
5448
+ */
5449
+ .replace(/([^\/])(:)(?=\d+)/, '$1\\$2')
5433
5450
  /**
5434
5451
  * Escape the protocol so that "path-to-regexp" could match
5435
5452
  * absolute URL.
5436
5453
  * @see https://github.com/pillarjs/path-to-regexp/issues/259
5437
5454
  */
5438
- .replace(/^([^\/]+)(:)(?=\/\/)/g, '$1\\$2'));
5455
+ .replace(/^([^\/]+)(:)(?=\/\/)/, '$1\\$2'));
5439
5456
  }
5440
5457
  /**
5441
5458
  * Returns the result of matching given request URL against a mask.
package/node/lib/index.js CHANGED
@@ -2863,11 +2863,12 @@ function parseMultipartData(data, headers) {
2863
2863
  * Parses a given request/response body based on the "Content-Type" header.
2864
2864
  */
2865
2865
  function parseBody(body, headers) {
2866
+ var _a;
2866
2867
  // Return whatever falsey body value is given.
2867
2868
  if (!body) {
2868
2869
  return body;
2869
2870
  }
2870
- const contentType = (headers === null || headers === void 0 ? void 0 : headers.get('content-type')) || '';
2871
+ const contentType = ((_a = headers === null || headers === void 0 ? void 0 : headers.get('content-type')) === null || _a === void 0 ? void 0 : _a.toLowerCase()) || '';
2871
2872
  // If the body has a Multipart Content-Type
2872
2873
  // parse it into an object.
2873
2874
  const hasMultipartContent = contentType.startsWith('multipart/form-data');
@@ -3110,11 +3111,9 @@ var InvariantError = /** @class */ (function (_super) {
3110
3111
  _this.name = 'Invariant Violation';
3111
3112
  _this.message = format_1.format.apply(void 0, __spreadArray([message], positionals));
3112
3113
  if (_this.stack) {
3113
- var prevStack = _this.stack;
3114
- _this.stack = prevStack
3115
- .split('\n')
3116
- .slice(STACK_FRAMES_TO_IGNORE)
3117
- .join('\n');
3114
+ var nextStack = _this.stack.split('\n');
3115
+ nextStack.splice(1, STACK_FRAMES_TO_IGNORE);
3116
+ _this.stack = nextStack.join('\n');
3118
3117
  }
3119
3118
  return _this;
3120
3119
  }
@@ -6818,7 +6817,9 @@ const createFetchRequestParameters = (input) => {
6818
6817
  if (['GET', 'HEAD'].includes(method)) {
6819
6818
  return requestParameters;
6820
6819
  }
6821
- if (typeof body === 'object' || typeof body === 'number') {
6820
+ if (typeof body === 'object' ||
6821
+ typeof body === 'number' ||
6822
+ typeof body === 'boolean') {
6822
6823
  requestParameters.body = JSON.stringify(body);
6823
6824
  }
6824
6825
  else {
@@ -7263,12 +7264,23 @@ function cleanUrl(path) {
7263
7264
  return path.replace(REDUNDANT_CHARACTERS_EXP, '');
7264
7265
  }
7265
7266
 
7267
+ /**
7268
+ * Determines if the given URL string is an absolute URL.
7269
+ */
7270
+ function isAbsoluteUrl(url) {
7271
+ return /^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(url);
7272
+ }
7273
+
7266
7274
  /**
7267
7275
  * Returns an absolute URL based on the given path.
7268
7276
  */
7269
7277
  function getAbsoluteUrl(path, baseUrl) {
7270
- // Ignore absolute URLs.
7271
- if (!path.startsWith('/')) {
7278
+ // already absolute URL
7279
+ if (isAbsoluteUrl(path)) {
7280
+ return path;
7281
+ }
7282
+ // Ignore path with pattern start with *
7283
+ if (path.startsWith('*')) {
7272
7284
  return path;
7273
7285
  }
7274
7286
  // Resolve a relative request URL against a given custom "baseUrl"
@@ -7316,12 +7328,17 @@ function coercePath(path) {
7316
7328
  ? `${parameterName}${wildcard}`
7317
7329
  : `${parameterName}${expression}`;
7318
7330
  })
7331
+ /**
7332
+ * Escape the port so that "path-to-regexp" can match
7333
+ * absolute URLs including port numbers.
7334
+ */
7335
+ .replace(/([^\/])(:)(?=\d+)/, '$1\\$2')
7319
7336
  /**
7320
7337
  * Escape the protocol so that "path-to-regexp" could match
7321
7338
  * absolute URL.
7322
7339
  * @see https://github.com/pillarjs/path-to-regexp/issues/259
7323
7340
  */
7324
- .replace(/^([^\/]+)(:)(?=\/\/)/g, '$1\\$2'));
7341
+ .replace(/^([^\/]+)(:)(?=\/\/)/, '$1\\$2'));
7325
7342
  }
7326
7343
  /**
7327
7344
  * Returns the result of matching given request URL against a mask.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "msw",
3
- "version": "0.36.3",
3
+ "version": "0.36.8",
4
4
  "description": "Seamless REST/GraphQL API mocking library for browser and Node.js.",
5
5
  "main": "lib/umd/index.js",
6
6
  "module": "lib/esm/index.js",
@@ -18,9 +18,8 @@
18
18
  "test:integration": "jest --config=test/jest.config.js --maxWorkers=3",
19
19
  "test:smoke": "config/scripts/smoke.sh",
20
20
  "test:ts": "tsc -p test/typings/tsconfig.json",
21
- "test:focused": "node node_modules/ts-node/dist/bin.js --project=test/tsconfig.json test/focusedTest.ts",
21
+ "prepare": "yarn simple-git-hooks init",
22
22
  "prepublishOnly": "yarn lint && yarn test:unit && yarn build && yarn test:integration",
23
- "prepare": "husky install",
24
23
  "postinstall": "node -e \"try{require('./config/scripts/postinstall')}catch(e){}\""
25
24
  },
26
25
  "lint-staged": {
@@ -64,7 +63,7 @@
64
63
  ],
65
64
  "sideEffects": false,
66
65
  "dependencies": {
67
- "@mswjs/cookies": "^0.1.6",
66
+ "@mswjs/cookies": "^0.1.7",
68
67
  "@mswjs/interceptors": "^0.12.7",
69
68
  "@open-draft/until": "^1.0.3",
70
69
  "@types/cookie": "^0.4.1",
@@ -78,7 +77,7 @@
78
77
  "inquirer": "^8.2.0",
79
78
  "is-node-process": "^1.0.1",
80
79
  "js-levenshtein": "^1.1.6",
81
- "node-fetch": "^2.6.1",
80
+ "node-fetch": "^2.6.7",
82
81
  "path-to-regexp": "^6.2.0",
83
82
  "statuses": "^2.0.0",
84
83
  "strict-event-emitter": "^0.2.0",
@@ -88,6 +87,8 @@
88
87
  "devDependencies": {
89
88
  "@babel/core": "^7.16.0",
90
89
  "@babel/preset-env": "^7.16.4",
90
+ "@commitlint/cli": "^16.0.2",
91
+ "@commitlint/config-conventional": "^16.0.0",
91
92
  "@open-draft/test-server": "^0.2.3",
92
93
  "@rollup/plugin-commonjs": "^19.0.0",
93
94
  "@rollup/plugin-inject": "^4.0.3",
@@ -104,17 +105,19 @@
104
105
  "@typescript-eslint/parser": "^4.28.3",
105
106
  "babel-loader": "^8.2.3",
106
107
  "babel-minify": "^0.5.1",
108
+ "commitizen": "^4.2.4",
107
109
  "cross-env": "^7.0.3",
108
110
  "cross-fetch": "^3.1.4",
111
+ "cz-conventional-changelog": "3.3.0",
109
112
  "eslint": "^7.30.0",
110
113
  "eslint-config-prettier": "^8.3.0",
111
114
  "eslint-plugin-prettier": "^3.4.0",
112
115
  "fs-extra": "^10.0.0",
113
116
  "fs-teardown": "^0.3.0",
114
- "husky": "^5.1.1",
115
117
  "jest": "26",
116
118
  "json-bigint": "^1.0.0",
117
119
  "lint-staged": "^11.0.1",
120
+ "outvariant": "^1.2.1",
118
121
  "page-with": "^0.5.0",
119
122
  "prettier": "^2.3.2",
120
123
  "regenerator-runtime": "^0.13.9",
@@ -122,6 +125,7 @@
122
125
  "rollup": "^2.60.2",
123
126
  "rollup-plugin-terser": "^7.0.2",
124
127
  "rollup-plugin-typescript2": "^0.30.0",
128
+ "simple-git-hooks": "^2.7.0",
125
129
  "ts-jest": "26",
126
130
  "ts-loader": "^9.2.6",
127
131
  "ts-node": "^10.1.0",
@@ -132,5 +136,10 @@
132
136
  },
133
137
  "resolutions": {
134
138
  "chokidar": "3.4.1"
139
+ },
140
+ "config": {
141
+ "commitizen": {
142
+ "path": "./node_modules/cz-conventional-changelog"
143
+ }
135
144
  }
136
145
  }