vite-plugin-mock-dev-server 0.3.11 → 0.3.13
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/dist/index.cjs +15 -12
- package/dist/index.js +15 -12
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -328,23 +328,26 @@ async function parseReqBody(req, options) {
|
|
|
328
328
|
if (["GET", "DELETE", "HEAD"].includes(method))
|
|
329
329
|
return void 0;
|
|
330
330
|
const type = req.headers["content-type"];
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
331
|
+
try {
|
|
332
|
+
if (type === "application/json") {
|
|
333
|
+
return await import_co_body.default.json(req);
|
|
334
|
+
}
|
|
335
|
+
if (type === "application/x-www-form-urlencoded") {
|
|
336
|
+
return await import_co_body.default.form(req);
|
|
337
|
+
}
|
|
338
|
+
if (type === "text/plain") {
|
|
339
|
+
return await import_co_body.default.text(req);
|
|
340
|
+
}
|
|
341
|
+
if (type == null ? void 0 : type.startsWith("multipart/form-data;")) {
|
|
342
|
+
return await parseMultipart(req, options);
|
|
343
|
+
}
|
|
344
|
+
} catch (e) {
|
|
345
|
+
console.error(e);
|
|
342
346
|
}
|
|
343
347
|
return void 0;
|
|
344
348
|
}
|
|
345
349
|
async function parseMultipart(req, options) {
|
|
346
350
|
const form = (0, import_formidable.default)(options);
|
|
347
|
-
debug("multiparty start");
|
|
348
351
|
return new Promise((resolve, reject) => {
|
|
349
352
|
form.parse(req, (error, fields, files) => {
|
|
350
353
|
if (error) {
|
package/dist/index.js
CHANGED
|
@@ -293,23 +293,26 @@ async function parseReqBody(req, options) {
|
|
|
293
293
|
if (["GET", "DELETE", "HEAD"].includes(method))
|
|
294
294
|
return void 0;
|
|
295
295
|
const type = req.headers["content-type"];
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
296
|
+
try {
|
|
297
|
+
if (type === "application/json") {
|
|
298
|
+
return await bodyParser.json(req);
|
|
299
|
+
}
|
|
300
|
+
if (type === "application/x-www-form-urlencoded") {
|
|
301
|
+
return await bodyParser.form(req);
|
|
302
|
+
}
|
|
303
|
+
if (type === "text/plain") {
|
|
304
|
+
return await bodyParser.text(req);
|
|
305
|
+
}
|
|
306
|
+
if (type == null ? void 0 : type.startsWith("multipart/form-data;")) {
|
|
307
|
+
return await parseMultipart(req, options);
|
|
308
|
+
}
|
|
309
|
+
} catch (e) {
|
|
310
|
+
console.error(e);
|
|
307
311
|
}
|
|
308
312
|
return void 0;
|
|
309
313
|
}
|
|
310
314
|
async function parseMultipart(req, options) {
|
|
311
315
|
const form = formidable(options);
|
|
312
|
-
debug("multiparty start");
|
|
313
316
|
return new Promise((resolve, reject) => {
|
|
314
317
|
form.parse(req, (error, fields, files) => {
|
|
315
318
|
if (error) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-plugin-mock-dev-server",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.13",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"vite",
|
|
6
6
|
"plugin",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"debug": "^4.3.4",
|
|
50
50
|
"esbuild": "^0.16.9",
|
|
51
51
|
"fast-glob": "^3.2.12",
|
|
52
|
-
"formidable": "
|
|
52
|
+
"formidable": "^2.1.1",
|
|
53
53
|
"json5": "^2.2.2",
|
|
54
54
|
"path-to-regexp": "^6.2.1"
|
|
55
55
|
},
|