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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/middlewares.js +15 -4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ultimate-express",
3
- "version": "1.2.6",
3
+ "version": "1.2.7",
4
4
  "description": "The Ultimate Express. Fastest http server with full Express compatibility, based on uWebSockets.",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -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(typeof options.type === 'function') {
177
- if(!options.type(req)) {
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(!typeis(req, options.type)) {
182
- return next();
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