Skip to content

Commit

Permalink
fix: getOptions change to clone
Browse files Browse the repository at this point in the history
  • Loading branch information
dead-horse committed Mar 24, 2017
1 parent eb10905 commit 39d2e74
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 12 deletions.
2 changes: 1 addition & 1 deletion lib/form.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ var utils = require('./utils');

module.exports = function(req, opts){
req = req.req || req;
opts = utils.getOptions(opts);
opts = utils.clone(opts);
var queryString = opts.queryString || {};

// keep compatibility with qs@4
Expand Down
2 changes: 1 addition & 1 deletion lib/json.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ var strictJSONReg = /^[\x20\x09\x0a\x0d]*(\[|\{)/;

module.exports = function(req, opts){
req = req.req || req;
opts = utils.getOptions(opts);
opts = utils.clone(opts);

// defaults
var len = req.headers['content-length'];
Expand Down
2 changes: 1 addition & 1 deletion lib/text.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ var utils = require('./utils');

module.exports = function(req, opts){
req = req.req || req;
opts = utils.getOptions(opts);
opts = utils.clone(opts);

// defaults
var len = req.headers['content-length'];
Expand Down
15 changes: 6 additions & 9 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,11 @@
* Module dependencies.
*/

exports.getOptions = function (opts) {
exports.clone = function (opts) {
var options = {};
opts = opts || {};
return {
limit: opts.limit,
strict: opts.strict,
queryString: opts.queryString,
qs: opts.qs,
returnRawBody: opts.returnRawBody,
encoding: opts.encoding,
};
for (var key in opts) {
options[key] = opts[key];
}
return options;
}

0 comments on commit 39d2e74

Please sign in to comment.