ultimate-express 1.1.9 → 1.2.0

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ultimate-express",
3
- "version": "1.1.9",
3
+ "version": "1.2.0",
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": {
@@ -44,6 +44,7 @@
44
44
  "cookie-signature": "^1.2.1",
45
45
  "encodeurl": "^2.0.0",
46
46
  "etag": "^1.8.1",
47
+ "fast-querystring": "^1.1.2",
47
48
  "fresh": "^0.5.2",
48
49
  "mime-types": "^2.1.35",
49
50
  "ms": "^2.1.3",
@@ -16,9 +16,8 @@ limitations under the License.
16
16
 
17
17
  const uWS = require("uWebSockets.js");
18
18
  const Router = require("./router.js");
19
- const { removeDuplicateSlashes, defaultSettings, compileTrust, createETagGenerator } = require("./utils.js");
20
- const querystring = require("querystring");
21
- const qs = require("qs");
19
+ const { removeDuplicateSlashes, defaultSettings, compileTrust, createETagGenerator, fastQueryParse } = require("./utils.js");
20
+ const querystring = require("fast-querystring");
22
21
  const ViewClass = require("./view.js");
23
22
  const path = require("path");
24
23
  const os = require("os");
@@ -117,7 +116,7 @@ class Application extends Router {
117
116
  }
118
117
  } else if(key === 'query parser') {
119
118
  if(value === 'extended') {
120
- this.settings['query parser fn'] = qs.parse;
119
+ this.settings['query parser fn'] = fastQueryParse;
121
120
  } else if(value === 'simple') {
122
121
  this.settings['query parser fn'] = querystring.parse;
123
122
  } else if(typeof value === 'function') {
package/src/utils.js CHANGED
@@ -18,9 +18,19 @@ const mime = require("mime-types");
18
18
  const path = require("path");
19
19
  const proxyaddr = require("proxy-addr");
20
20
  const qs = require("qs");
21
+ const querystring = require("fast-querystring");
21
22
  const etag = require("etag");
22
23
  const { Stats } = require("fs");
23
24
 
25
+ function fastQueryParse(query) {
26
+ if(query.length <= 128) {
27
+ if(!query.includes('[') && !query.includes('%5B') && !query.includes('.') && !query.includes('%2E')) {
28
+ return querystring.parse(query);
29
+ }
30
+ }
31
+ return qs.parse(query);
32
+ }
33
+
24
34
  function removeDuplicateSlashes(path) {
25
35
  return path.replace(/\/{2,}/g, '/');
26
36
  }
@@ -115,7 +125,7 @@ const defaultSettings = {
115
125
  'etag': 'weak',
116
126
  'etag fn': () => createETagGenerator({ weak: true }),
117
127
  'query parser': 'extended',
118
- 'query parser fn': () => qs.parse,
128
+ 'query parser fn': () => fastQueryParse,
119
129
  'subdomain offset': 2,
120
130
  'trust proxy': false,
121
131
  'views': () => path.join(process.cwd(), 'views'),
@@ -300,5 +310,6 @@ module.exports = {
300
310
  isPreconditionFailure,
301
311
  createETagGenerator,
302
312
  isRangeFresh,
303
- findIndexStartingFrom
313
+ findIndexStartingFrom,
314
+ fastQueryParse
304
315
  };