Skip to content
Myr

req.query.js

This file

Path

test/req.query.js

95 lines · 2.3 KiB · JavaScript

Last changed by

Add configurable query parserDouglas Christopher Wilsonbefore adoptione29fa25

History of this file

Take it

The walk stopped after 200 commits: lines older than 2377fc8 point at it.

update serve-static to 1.0.4Douglas Christopher Wilsonbefore adoption2377fc8

lines 1–7why, one step back
1
2var express = require('../')3 , request = require('supertest');45describe('req', function(){6 describe('.query', function(){7 it('should default to {}', function(done){

Add configurable query parserDouglas Christopher Wilsonbefore adoptione29fa25

line 8why, one step back
8 var app = createApp();

update serve-static to 1.0.4Douglas Christopher Wilsonbefore adoption2377fc8

lines 9–11why, one step back
9
10 request(app)11 .get('/')

Add configurable query parserDouglas Christopher Wilsonbefore adoptione29fa25

lines 12–29why, one step back
12 .expect(200, '{}', done);
13 });1415 it('should default to parse complex keys', function (done) {16 var app = createApp();1718 request(app)19 .get('/?user[name]=tj')20 .expect(200, '{"user":{"name":"tj"}}', done);21 });2223 describe('when "query parser" is extended', function () {24 it('should parse complex keys', function (done) {25 var app = createApp('extended');2627 request(app)28 .get('/?user[name]=tj')29 .expect(200, '{"user":{"name":"tj"}}', done);

update serve-static to 1.0.4Douglas Christopher Wilsonbefore adoption2377fc8

line 30why, one step back
30 });

Add configurable query parserDouglas Christopher Wilsonbefore adoptione29fa25

line 31why, one step back
31 });

update serve-static to 1.0.4Douglas Christopher Wilsonbefore adoption2377fc8

line 32why, one step back
32

Add configurable query parserDouglas Christopher Wilsonbefore adoptione29fa25

lines 33–35why, one step back
33 describe('when "query parser" is simple', function () {
34 it('should not parse complex keys', function (done) {35 var app = createApp('simple');

update serve-static to 1.0.4Douglas Christopher Wilsonbefore adoption2377fc8

line 36why, one step back
36

Add configurable query parserDouglas Christopher Wilsonbefore adoptione29fa25

lines 37–39why, one step back
37 request(app)
38 .get('/?user[name]=tj')39 .expect(200, '{"user[name]":"tj"}', done);

update serve-static to 1.0.4Douglas Christopher Wilsonbefore adoption2377fc8

line 40why, one step back
40 });

Add configurable query parserDouglas Christopher Wilsonbefore adoptione29fa25

line 41why, one step back
41 });

update serve-static to 1.0.4Douglas Christopher Wilsonbefore adoption2377fc8

line 42why, one step back
42

Add configurable query parserDouglas Christopher Wilsonbefore adoptione29fa25

lines 43–51why, one step back
43 describe('when "query parser" is a function', function () {
44 it('should parse using function', function (done) {45 var app = createApp(function (str) {46 return {'length': (str || '').length};47 });4849 request(app)50 .get('/?user[name]=tj')51 .expect(200, '{"length":17}', done);

update serve-static to 1.0.4Douglas Christopher Wilsonbefore adoption2377fc8

line 52why, one step back
52 });

Add configurable query parserDouglas Christopher Wilsonbefore adoptione29fa25

lines 53–79why, one step back
53 });
5455 describe('when "query parser" disabled', function () {56 it('should not parse query', function (done) {57 var app = createApp(false);5859 request(app)60 .get('/?user[name]=tj')61 .expect(200, '{}', done);62 });63 });6465 describe('when "query parser" disabled', function () {66 it('should not parse complex keys', function (done) {67 var app = createApp(true);6869 request(app)70 .get('/?user[name]=tj')71 .expect(200, '{"user[name]":"tj"}', done);72 });73 });7475 describe('when "query parser" an unknown value', function () {76 it('should throw', function () {77 createApp.bind(null, 'bogus').should.throw(/unknown value.*query parser/);78 });79 });

update serve-static to 1.0.4Douglas Christopher Wilsonbefore adoption2377fc8

lines 80–81why, one step back
80 })
81})

Add configurable query parserDouglas Christopher Wilsonbefore adoptione29fa25

lines 82–95why, one step back
82
83function createApp(setting) {84 var app = express();8586 if (setting !== undefined) {87 app.set('query parser', setting);88 }8990 app.use(function (req, res) {91 res.send(req.query);92 });9394 return app;95}