deps: qs@4.0.0
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Douglas Christopher Wilson · committed by Douglas Christopher Wilson · parent 3314f76 · Browse files · 5 files·+57 added−4 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
5 files+57 added−4 removed
- tests:+25 added−0 removed
- other:+32 added−4 removed
Provenance
- Commit
7bea53b- Tree
847317b- Author
Douglas Christopher Wilson <doug@somethingdoug.com>- Committer
Douglas Christopher Wilson <doug@somethingdoug.com>- Parent
3314f76
5 files changed+57 added−4 removed
modified:lib/middleware/query.js+13 added-2 removed
20 unmodified lines21222324252627282929303132333435363738394041424344453546474849505120 unmodified lines * @api public */
module.exports = function query(options) { var opts = Object.create(options || null); var queryparse = qs.parse;
if (typeof options === 'function') { queryparse = options; options = undefined; opts = undefined; }
if (opts !== undefined) { if (opts.allowDots === undefined) { opts.allowDots = false; }
if (opts.allowPrototypes === undefined) { opts.allowPrototypes = true; } }
return function query(req, res, next){ if (!req.query) { var val = parseUrl(req).query; req.query = queryparse(val, options); req.query = queryparse(val, opts); }
next(); };};modified:lib/utils.js+15 added-1 removed
207 unmodified lines208 case false:209 fn = newObject;210 break;211 case 'extended':212- fn = qs.parse;212+ fn = parseExtendedQueryString;213 break;214 case 'simple':215 fn = querystring.parse;216 break;57 unmodified lines274 return contentType.format(parsed);275 };276 277 /**278+ * Parse an extended query string with qs.279+ *280+ * @return {Object}281+ * @private282+ */283+284+function parseExtendedQueryString(str) {285+ return qs.parse(str, {286+ allowDots: false,287+ allowPrototypes: true288+ });289+}290+291+/**292 * Return new empty object.293 *294 * @return {Object}295 * @api private5 unmodified linesmodified:test/req.query.js+25 added
26 unmodified lines2728293031323334353637383940414236 unmodified lines79808182838485868788899091929394959697989910010110210317 unmodified lines26 unmodified lines request(app) .get('/?user[name]=tj') .expect(200, '{"user":{"name":"tj"}}', done); });
it('should parse parameters with dots', function (done) { var app = createApp('extended');
request(app) .get('/?user.name=tj') .expect(200, '{"user.name":"tj"}', done); }); });
describe('when "query parser" is simple', function () { it('should not parse complex keys', function (done) {36 unmodified lines .expect(200, '{"user[name]":"tj"}', done); }); });
describe('when "query parser fn" is missing', function () { it('should act like "extended"', function (done) { var app = express();
delete app.settings['query parser']; delete app.settings['query parser fn'];
app.use(function (req, res) { res.send(req.query); });
request(app) .get('/?user[name]=tj&user.name=tj') .expect(200, '{"user":{"name":"tj"},"user.name":"tj"}', done); }); });
describe('when "query parser" an unknown value', function () { it('should throw', function () { createApp.bind(null, 'bogus').should.throw(/unknown value.*query parser/); });17 unmodified linesmodified:History.md+3 added
1 unmodified line2 ==========3 4 * deps: accepts@~1.2.105 - deps: mime-types@~2.1.26+ * deps: qs@4.0.07+ - Fix dropping parameters like `hasOwnProperty`8+ - Fix various parsing edge cases9 * deps: type-is@~1.6.410 - deps: mime-types@~2.1.211 - perf: enable strict mode12 - perf: remove argument reassignment2979 unmodified linesmodified:package.json+1 added-1 removed
43 unmodified lines44 "on-finished": "~2.3.0",45 "parseurl": "~1.3.0",46 "path-to-regexp": "0.1.6",47 "proxy-addr": "~1.0.8",48- "qs": "2.4.2",48+ "qs": "4.0.0",49 "range-parser": "~1.0.2",50 "send": "0.13.0",51 "serve-static": "~1.10.0",52 "type-is": "~1.6.4",39 unmodified lines