Skip to content
Myr

req.query.js

This file

Path

test/req.query.js

106 lines · 2.6 KiB · JavaScript

Last changed by

fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359

History of this file

Take it

The walk stopped after 200 commits: lines older than 2a0c35a point at it.

Merge tag '4.17.3'Douglas Christopher Wilsonbefore adoption318fd4b

line 1why, one step back
1'use strict'

Invoke callback for sendfile when client abortsDouglas Christopher Wilsonbefore adoption2a0c35a

line 2why, one step back
2

fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359

line 3why, one step back
3var assert = require('node:assert')

Invoke callback for sendfile when client abortsDouglas Christopher Wilsonbefore adoption2a0c35a

lines 4–16why, one step back
4var express = require('../')
5 , request = require('supertest');67describe('req', function(){8 describe('.query', function(){9 it('should default to {}', function(done){10 var app = createApp();1112 request(app)13 .get('/')14 .expect(200, '{}', done);15 });16

Change query parser setting default to 'simple'Czarekbefore adoption450c468

line 17why, one step back
17 it('should default to parse simple keys', function (done) {

Invoke callback for sendfile when client abortsDouglas Christopher Wilsonbefore adoption2a0c35a

lines 18–21why, one step back
18 var app = createApp();
1920 request(app)21 .get('/?user[name]=tj')

Change query parser setting default to 'simple'Czarekbefore adoption450c468

line 22why, one step back
22 .expect(200, '{"user[name]":"tj"}', done);

Invoke callback for sendfile when client abortsDouglas Christopher Wilsonbefore adoption2a0c35a

lines 23–29why, one step back
23 });
2425 describe('when "query parser" is extended', function () {26 it('should parse complex keys', function (done) {27 var app = createApp('extended');2829 request(app)

Merge tag '4.17.1'Douglas Christopher Wilsonbefore adoption121fe99

lines 30–31why, one step back
30 .get('/?foo[0][bar]=baz&foo[0][fizz]=buzz&foo[]=done!')
31 .expect(200, '{"foo":[{"bar":"baz","fizz":"buzz"},"done!"]}', done);

Invoke callback for sendfile when client abortsDouglas Christopher Wilsonbefore adoption2a0c35a

line 32why, one step back
32 });

Merge tag '4.13.1'Douglas Christopher Wilsonbefore adoptionb309b87

lines 33–40why, one step back
33
34 it('should parse parameters with dots', function (done) {35 var app = createApp('extended');3637 request(app)38 .get('/?user.name=tj')39 .expect(200, '{"user.name":"tj"}', done);40 });

Invoke callback for sendfile when client abortsDouglas Christopher Wilsonbefore adoption2a0c35a

lines 41–47why, one step back
41 });
4243 describe('when "query parser" is simple', function () {44 it('should not parse complex keys', function (done) {45 var app = createApp('simple');4647 request(app)

Merge tag '4.14.0'Douglas Christopher Wilsonbefore adoption1dbfee6

line 48why, one step back
48 .get('/?user%5Bname%5D=tj')

Invoke callback for sendfile when client abortsDouglas Christopher Wilsonbefore adoption2a0c35a

lines 49–59why, one step back
49 .expect(200, '{"user[name]":"tj"}', done);
50 });51 });5253 describe('when "query parser" is a function', function () {54 it('should parse using function', function (done) {55 var app = createApp(function (str) {56 return {'length': (str || '').length};57 });5859 request(app)

Merge tag '4.14.0'Douglas Christopher Wilsonbefore adoption1dbfee6

line 60why, one step back
60 .get('/?user%5Bname%5D=tj')

Invoke callback for sendfile when client abortsDouglas Christopher Wilsonbefore adoption2a0c35a

lines 61–69why, one step back
61 .expect(200, '{"length":17}', done);
62 });63 });6465 describe('when "query parser" disabled', function () {66 it('should not parse query', function (done) {67 var app = createApp(false);6869 request(app)

Merge tag '4.14.0'Douglas Christopher Wilsonbefore adoption1dbfee6

line 70why, one step back
70 .get('/?user%5Bname%5D=tj')

Invoke callback for sendfile when client abortsDouglas Christopher Wilsonbefore adoption2a0c35a

lines 71–74why, one step back
71 .expect(200, '{}', done);
72 });73 });74

Merge tag '4.17.1'Douglas Christopher Wilsonbefore adoption121fe99

line 75why, one step back
75 describe('when "query parser" enabled', function () {

Invoke callback for sendfile when client abortsDouglas Christopher Wilsonbefore adoption2a0c35a

lines 76–79why, one step back
76 it('should not parse complex keys', function (done) {
77 var app = createApp(true);7879 request(app)

Merge tag '4.14.0'Douglas Christopher Wilsonbefore adoption1dbfee6

line 80why, one step back
80 .get('/?user%5Bname%5D=tj')

Invoke callback for sendfile when client abortsDouglas Christopher Wilsonbefore adoption2a0c35a

lines 81–86why, one step back
81 .expect(200, '{"user[name]":"tj"}', done);
82 });83 });8485 describe('when "query parser" an unknown value', function () {86 it('should throw', function () {

Merge tag '4.17.3'Douglas Christopher Wilsonbefore adoption318fd4b

lines 87–88why, one step back
87 assert.throws(createApp.bind(null, 'bogus'),
88 /unknown value.*query parser/)

Invoke callback for sendfile when client abortsDouglas Christopher Wilsonbefore adoption2a0c35a

lines 89–106why, one step back
89 });
90 });91 })92})9394function createApp(setting) {95 var app = express();9697 if (setting !== undefined) {98 app.set('query parser', setting);99 }100101 app.use(function (req, res) {102 res.send(req.query);103 });104105 return app;106}