Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moves compileQueryParser to separate module #3259

Open
wants to merge 1 commit into
base: 5.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ var debug = require('debug')('express:application');
var View = require('./view');
var http = require('http');
var compileETag = require('./utils').compileETag;
var compileQueryParser = require('./utils').compileQueryParser;
var compileQueryParser = require('compile-query-parser');
var compileTrust = require('./utils').compileTrust;
var flatten = require('array-flatten');
var merge = require('utils-merge');
Expand Down
49 changes: 0 additions & 49 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ var contentType = require('content-type');
var etag = require('etag');
var flatten = require('array-flatten');
var proxyaddr = require('proxy-addr');
var qs = require('qs');
var querystring = require('querystring');

/**
* Return strong ETag for `body`.
Expand Down Expand Up @@ -146,40 +144,6 @@ exports.compileETag = function(val) {
return fn;
}

/**
* Compile "query parser" value to function.
*
* @param {String|Function} val
* @return {Function}
* @api private
*/

exports.compileQueryParser = function compileQueryParser(val) {
var fn;

if (typeof val === 'function') {
return val;
}

switch (val) {
case true:
fn = querystring.parse;
break;
case false:
break;
case 'extended':
fn = parseExtendedQueryString;
break;
case 'simple':
fn = querystring.parse;
break;
default:
throw new TypeError('unknown value for query parser function: ' + val);
}

return fn;
}

/**
* Compile "proxy trust" value to function.
*
Expand Down Expand Up @@ -232,16 +196,3 @@ exports.setCharset = function setCharset(type, charset) {
// format type
return contentType.format(parsed);
};

/**
* Parse an extended query string with qs.
*
* @return {Object}
* @private
*/

function parseExtendedQueryString(str) {
return qs.parse(str, {
allowPrototypes: true
});
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"dependencies": {
"accepts": "~1.3.3",
"array-flatten": "2.1.1",
"compile-query-parser": "~1.0.1",
"content-disposition": "0.5.2",
"content-type": "~1.0.2",
"cookie": "0.3.1",
Expand Down