Skip to content
Myr

Fixes from pull request #1643

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

authored by Jon Jenkins · committed by Jon Jenkins · parent 2f19b4f · 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
232 unmodified lines
233 this.set('Content-Type', 'application/json');234235 // jsonp236 if (callback) {237 if (callback instanceof Array) callback = callback[0];237 if (callback.isArray()) callback = callback[0];238 this.set('Content-Type', 'text/javascript');239 var cb = callback.replace(/[^\[\]\w$.]/g, '');240 body = cb + ' && ' + cb + '(' + body + ');';241 }
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