Skip to content
Myr

Merge pull request #1711 from jonjenkins/master

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

Fixes from pull request #1643

authored by TJ Holowaychuk · committed by TJ Holowaychuk · parents f1c46f5, 19cb398 · Browse files · 2 files+17 added−1 removed
This commit

State

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

Diff stats

2 files+17 added−1 removed

  • tests:+16 added−0 removed
  • other:+1 added−1 removed

2 files+17 added−1 removed

modified:lib/response.js+1 added-1 removed
235 unmodified lines
236 this.set('Content-Type', 'application/json');237238 // jsonp239 if (callback) {240 if (callback instanceof Array) callback = callback[0];240 if (Array.isArray(callback)) callback = callback[0];241 this.set('Content-Type', 'text/javascript');242 var cb = callback.replace(/[^\[\]\w$.]/g, '');243 body = cb + ' && ' + cb + '(' + body + ');';244 }
517 unmodified lines
modified:test/res.jsonp.js+16 added
19 unmodified lines
20 done();21 })22 })2324 it('should use first callback parameter with jsonp', function(done){25 var app = express();2627 app.use(function(req, res){28 res.jsonp({ count: 1 });29 });3031 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});');36 done();37 })38 })3940 it('should allow renaming callback', function(done){41 var app = express();4243 app.set('jsonp callback name', 'clb');
209 unmodified lines