Skip to content
Myr

Merge branch 'master' of github.com:visionmedia/express

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by TJ Holowaychuk · committed by TJ Holowaychuk · parents 9cbcf23, 36e42db · Browse files · 5 files+44 added−35 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+44 added−35 removed

  • tests:+9 added−9 removed
  • other:+35 added−26 removed

5 files+44 added−35 removed

modified:lib/response.js+2 added-2 removed
240 unmodified lines
241 if (callback) {242 if (Array.isArray(callback)) callback = callback[0];243 this.set('Content-Type', 'text/javascript');244 var cb = callback.replace(/[^\[\]\w$.]/g, '');245 body = cb + ' && ' + cb + '(' + body + ');';245 body = 'typeof ' + cb + ' === \'function\' && ' + cb + '(' + body + ');';246 }247248 return this.send(body);249};
499 unmodified lines
749 }750751 var vary = this.get('Vary');752753 // append 753 // append754 if (vary) {755 vary = vary.split(/ *, */);756 if (!~vary.indexOf(field)) vary.push(field);757 this.set('Vary', vary.join(', '));
47 unmodified lines
modified:test/res.jsonp.js+9 added-9 removed
14 unmodified lines
15 request(app)16 .get('/?callback=something')17 .end(function(err, res){18 res.headers.should.have.property('content-type', 'text/javascript; charset=utf-8');19 res.text.should.equal('something && something({"count":1});');19 res.text.should.equal('typeof something === \'function\' && something({"count":1});');20 done();21 })22 })23
7 unmodified lines
31 request(app)32 .get('/?callback=something&callback=somethingelse')33 .end(function(err, res){34 res.headers.should.have.property('content-type', 'text/javascript; charset=utf-8');35 res.text.should.equal('something && something({"count":1});');35 res.text.should.equal('typeof something === \'function\' && something({"count":1});');36 done();37 })38 })39
9 unmodified lines
49 request(app)50 .get('/?clb=something')51 .end(function(err, res){52 res.headers.should.have.property('content-type', 'text/javascript; charset=utf-8');53 res.text.should.equal('something && something({"count":1});');53 res.text.should.equal('typeof something === \'function\' && something({"count":1});');54 done();55 })56 }) 56 })5758 it('should allow []', function(done){59 var app = express();60
4 unmodified lines
65 request(app)66 .get('/?callback=callbacks[123]')67 .end(function(err, res){68 res.headers.should.have.property('content-type', 'text/javascript; charset=utf-8');69 res.text.should.equal('callbacks[123] && callbacks[123]({"count":1});');69 res.text.should.equal('typeof callbacks[123] === \'function\' && callbacks[123]({"count":1});');70 done();71 })72 })73
7 unmodified lines
81 request(app)82 .get('/?callback=foo;bar()')83 .end(function(err, res){84 res.headers.should.have.property('content-type', 'text/javascript; charset=utf-8');85 res.text.should.equal('foobar && foobar({});');85 res.text.should.equal('typeof foobar === \'function\' && foobar({});');86 done();87 })88 })89
7 unmodified lines
97 request(app)98 .get('/?callback=foo')99 .end(function(err, res){100 res.headers.should.have.property('content-type', 'text/javascript; charset=utf-8');101 res.text.should.equal('foo && foo({"str":"\\u2028 \\u2029 woot"});');101 res.text.should.equal('typeof foo === \'function\' && foo({"str":"\\u2028 \\u2029 woot"});');102 done();103 });104 });105
31 unmodified lines
137 done();138 })139 })140 })141 141142 describe('when given an object', function(){143 it('should respond with json', function(done){144 var app = express();145
64 unmodified lines
210 });211 })212 })213 })214 214215 describe('.json(status, object)', function(){216 it('should respond with json and set the .statusCode', function(done){217 var app = express();218
34 unmodified lines
modified:History.md+30 added-22 removed
13.4.1 / 2013-10-152==================3 * update connect4 * update commander5 * jsonp: check if callback is a function6 * router: wrap encodeURIComponent in a try/catch #1735 (@lxe)7 * res.format: now includes chraset @1747 (@sorribas)8 * res.links: allow multiple calls @1746 (@sorribas)923.4.0 / 2013-09-07 103.4.0 / 2013-09-0711==================1213 * add res.vary(). Closes #168214 * update connect1583.3.8 / 2013-09-02 163.3.8 / 2013-09-0217==================1819 * update connect20133.3.7 / 2013-08-28 213.3.7 / 2013-08-2822==================2324 * update connect25183.3.6 / 2013-08-27 263.3.6 / 2013-08-2727==================2829 * Revert "remove charset from json responses. Closes #1631" (causes issues in some clients)30 * add: req.accepts take an argument list31243.3.4 / 2013-07-08 323.3.4 / 2013-07-0833==================3435 * update send and connect36293.3.3 / 2013-07-04 373.3.3 / 2013-07-0438==================3940 * update connect41343.3.2 / 2013-07-03 423.3.2 / 2013-07-0343==================4445 * update connect46 * update send47 * remove .version export48413.3.1 / 2013-06-27 493.3.1 / 2013-06-2750==================5152 * update connect53463.3.0 / 2013-06-26 543.3.0 / 2013-06-2655==================5657 * update connect58 * add support for multiple X-Forwarded-Proto values. Closes #164659 * change: remove charset from json responses. Closes #163160 * change: return actual booleans from req.accept* functions61 * fix jsonp callback array throw62553.2.6 / 2013-06-02 633.2.6 / 2013-06-0264==================6566 * update connect67603.2.5 / 2013-05-21 683.2.5 / 2013-05-2169==================7071 * update connect72 * update node-cookie73 * add: throw a meaningful error when there is no default engine74 * change generation of ETags with res.send() to GET requests only. Closes #161975683.2.4 / 2013-05-09 763.2.4 / 2013-05-0977==================70 7879 * fix `req.subdomains` when no Host is present80 * fix `req.host` when no Host is present, return undefined81743.2.3 / 2013-05-07 823.2.3 / 2013-05-0783==================8485 * update connect / qs86793.2.2 / 2013-05-03 873.2.2 / 2013-05-0388==================8990 * update qs91843.2.1 / 2013-04-29 923.2.1 / 2013-04-2993==================9495 * add app.VERB() paths array deprecation warning96 * update connect97 * update qs and remove all ~ semver crap98 * fix: accept number as value of Signed Cookie99923.2.0 / 2013-04-15 1003.2.0 / 2013-04-15101==================102103 * add "view" constructor setting to override view behaviour104 * add req.acceptsEncoding(name)105 * add req.acceptedEncodings106 * revert cookie signature change causing session race conditions99 * fix sorting of Accept values of the same quality 107 * fix sorting of Accept values of the same quality1081013.1.2 / 2013-04-12 1093.1.2 / 2013-04-12110==================111112 * add support for custom Accept parameters113 * update cookie-signature1141073.1.1 / 2013-04-01 1153.1.1 / 2013-04-01116==================117118 * add X-Forwarded-Host support to `req.host`111 * fix relative redirects 112 * update mkdirp 119 * fix relative redirects120 * update mkdirp121 * update buffer-crc32122 * remove legacy app.configure() method from app template.1231243.1.0 / 2013-01-25
1089 unmodified lines
modified:Makefile+1 added
7 unmodified lines
89test-unit:10 @NODE_ENV=test ./node_modules/.bin/mocha \11 --reporter $(REPORTER) \12 --globals setImmediate,clearImmediate \13 $(MOCHA_OPTS)1415test-acceptance:16 @NODE_ENV=test ./node_modules/.bin/mocha \
18 unmodified lines
modified:package.json+2 added-2 removed