ultimate-express 1.2.6 → 1.2.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/package.json +1 -1
- package/src/middlewares.js +15 -4
package/package.json
CHANGED
package/src/middlewares.js
CHANGED
|
@@ -143,6 +143,9 @@ function createBodyParser(defaultType, beforeReturn) {
|
|
|
143
143
|
}
|
|
144
144
|
if(typeof options.inflate === 'undefined') options.inflate = true;
|
|
145
145
|
if(typeof options.type === 'string') {
|
|
146
|
+
if(!options.type.includes("*")) {
|
|
147
|
+
options.simpleType = options.type;
|
|
148
|
+
}
|
|
146
149
|
options.type = [options.type];
|
|
147
150
|
} else if(typeof options.type !== 'function' && !Array.isArray(options.type)) {
|
|
148
151
|
throw new Error('type must be a string, function or an array');
|
|
@@ -173,13 +176,21 @@ function createBodyParser(defaultType, beforeReturn) {
|
|
|
173
176
|
return next(new Error('Request entity too large'));
|
|
174
177
|
}
|
|
175
178
|
|
|
176
|
-
if(
|
|
177
|
-
|
|
179
|
+
if(options.simpleType) {
|
|
180
|
+
const semicolonIndex = type.indexOf(';');
|
|
181
|
+
const clearType = semicolonIndex !== -1 ? type.substring(0, semicolonIndex) : type;
|
|
182
|
+
if(clearType !== options.simpleType) {
|
|
178
183
|
return next();
|
|
179
184
|
}
|
|
180
185
|
} else {
|
|
181
|
-
if(
|
|
182
|
-
|
|
186
|
+
if(typeof options.type === 'function') {
|
|
187
|
+
if(!options.type(req)) {
|
|
188
|
+
return next();
|
|
189
|
+
}
|
|
190
|
+
} else {
|
|
191
|
+
if(!typeis(req, options.type)) {
|
|
192
|
+
return next();
|
|
193
|
+
}
|
|
183
194
|
}
|
|
184
195
|
}
|
|
185
196
|
|