tezx 1.0.27 → 1.0.29
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/cjs/index.js +1 -1
- package/cjs/utils/formData.js +19 -2
- package/index.js +1 -1
- package/package.json +1 -1
- package/utils/formData.js +19 -2
package/cjs/index.js
CHANGED
|
@@ -7,4 +7,4 @@ var server_1 = require("./core/server");
|
|
|
7
7
|
Object.defineProperty(exports, "TezX", { enumerable: true, get: function () { return server_1.TezX; } });
|
|
8
8
|
var params_1 = require("./utils/params");
|
|
9
9
|
Object.defineProperty(exports, "useParams", { enumerable: true, get: function () { return params_1.useParams; } });
|
|
10
|
-
exports.version = "1.0.
|
|
10
|
+
exports.version = "1.0.29";
|
package/cjs/utils/formData.js
CHANGED
|
@@ -93,7 +93,6 @@ async function parseUrlEncodedBody(req) {
|
|
|
93
93
|
}
|
|
94
94
|
async function parseMultipartBody(req, boundary, options) {
|
|
95
95
|
const runtime = environment_1.EnvironmentDetector.getEnvironment;
|
|
96
|
-
const x = options?.sanitized;
|
|
97
96
|
if (runtime === "node") {
|
|
98
97
|
return new Promise((resolve, reject) => {
|
|
99
98
|
let body = "";
|
|
@@ -109,7 +108,17 @@ async function parseMultipartBody(req, boundary, options) {
|
|
|
109
108
|
if (match && match.length === 3) {
|
|
110
109
|
const name = match[1];
|
|
111
110
|
const value = match[2];
|
|
112
|
-
formDataField[name]
|
|
111
|
+
if (formDataField[name]) {
|
|
112
|
+
if (Array.isArray(formDataField[name])) {
|
|
113
|
+
formDataField[name].push(value);
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
formDataField[name] = [formDataField[name], value];
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
formDataField[name] = value;
|
|
121
|
+
}
|
|
113
122
|
}
|
|
114
123
|
});
|
|
115
124
|
const parts = body.split(`--${boundary}`);
|
|
@@ -153,6 +162,10 @@ async function parseMultipartBody(req, boundary, options) {
|
|
|
153
162
|
formDataField[fieldName].push(file);
|
|
154
163
|
}
|
|
155
164
|
else {
|
|
165
|
+
if (typeof options?.maxFiles != "undefined" &&
|
|
166
|
+
options.maxFiles == 1) {
|
|
167
|
+
reject(new Error(`Field "${fieldName}" exceeds the maximum allowed file count of ${options.maxFiles}.`));
|
|
168
|
+
}
|
|
156
169
|
formDataField[fieldName] = [formDataField[fieldName], file];
|
|
157
170
|
}
|
|
158
171
|
}
|
|
@@ -204,6 +217,10 @@ async function parseMultipartBody(req, boundary, options) {
|
|
|
204
217
|
result[key].push(val);
|
|
205
218
|
}
|
|
206
219
|
else {
|
|
220
|
+
if (val instanceof File &&
|
|
221
|
+
typeof options?.maxFiles != "undefined" && options.maxFiles == 1) {
|
|
222
|
+
throw new Error(`Field "${key}" exceeds the maximum allowed file count of ${options.maxFiles}.`);
|
|
223
|
+
}
|
|
207
224
|
result[key] = [result[key], val];
|
|
208
225
|
}
|
|
209
226
|
}
|
package/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tezx",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.29",
|
|
4
4
|
"description": "TezX is a high-performance, lightweight JavaScript framework designed for speed, scalability, and flexibility. It enables efficient routing, middleware management, and static file serving with minimal configuration. Fully compatible with Node.js, Deno, and Bun.",
|
|
5
5
|
"main": "cjs/index.js",
|
|
6
6
|
"module": "index.js",
|
package/utils/formData.js
CHANGED
|
@@ -87,7 +87,6 @@ export async function parseUrlEncodedBody(req) {
|
|
|
87
87
|
}
|
|
88
88
|
export async function parseMultipartBody(req, boundary, options) {
|
|
89
89
|
const runtime = EnvironmentDetector.getEnvironment;
|
|
90
|
-
const x = options?.sanitized;
|
|
91
90
|
if (runtime === "node") {
|
|
92
91
|
return new Promise((resolve, reject) => {
|
|
93
92
|
let body = "";
|
|
@@ -103,7 +102,17 @@ export async function parseMultipartBody(req, boundary, options) {
|
|
|
103
102
|
if (match && match.length === 3) {
|
|
104
103
|
const name = match[1];
|
|
105
104
|
const value = match[2];
|
|
106
|
-
formDataField[name]
|
|
105
|
+
if (formDataField[name]) {
|
|
106
|
+
if (Array.isArray(formDataField[name])) {
|
|
107
|
+
formDataField[name].push(value);
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
formDataField[name] = [formDataField[name], value];
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
formDataField[name] = value;
|
|
115
|
+
}
|
|
107
116
|
}
|
|
108
117
|
});
|
|
109
118
|
const parts = body.split(`--${boundary}`);
|
|
@@ -147,6 +156,10 @@ export async function parseMultipartBody(req, boundary, options) {
|
|
|
147
156
|
formDataField[fieldName].push(file);
|
|
148
157
|
}
|
|
149
158
|
else {
|
|
159
|
+
if (typeof options?.maxFiles != "undefined" &&
|
|
160
|
+
options.maxFiles == 1) {
|
|
161
|
+
reject(new Error(`Field "${fieldName}" exceeds the maximum allowed file count of ${options.maxFiles}.`));
|
|
162
|
+
}
|
|
150
163
|
formDataField[fieldName] = [formDataField[fieldName], file];
|
|
151
164
|
}
|
|
152
165
|
}
|
|
@@ -198,6 +211,10 @@ export async function parseMultipartBody(req, boundary, options) {
|
|
|
198
211
|
result[key].push(val);
|
|
199
212
|
}
|
|
200
213
|
else {
|
|
214
|
+
if (val instanceof File &&
|
|
215
|
+
typeof options?.maxFiles != "undefined" && options.maxFiles == 1) {
|
|
216
|
+
throw new Error(`Field "${key}" exceeds the maximum allowed file count of ${options.maxFiles}.`);
|
|
217
|
+
}
|
|
201
218
|
result[key] = [result[key], val];
|
|
202
219
|
}
|
|
203
220
|
}
|