Skip to content
Myr

add "jsonp callback name" setting

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

authored by riadh · committed by TJ Holowaychuk · parent b9e32ec · Browse files · 3 files+20 added−3 removed
This commit

State

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

Diff stats

3 files+20 added−3 removed

  • tests:+17 added−0 removed
  • other:+3 added−3 removed

3 files+20 added−3 removed

modified:lib/application.js+1 added
81 unmodified lines
82 this.locals.settings = this.settings;8384 // default configuration85 this.enable('jsonp callback');86 this.set('jsonp callback name', 'callback');8788 this.configure('development', function(){89 this.set('json spaces', 2);90 });
442 unmodified lines
modified:lib/response.js+2 added-3 removed
11/**2 * Module dependencies.3 */4
106 unmodified lines
111 , jsonp = app.get('jsonp callback')112 , replacer = app.get('json replacer')113 , spaces = app.get('json spaces')114 , body = JSON.stringify(obj, replacer, spaces)116 , callback = this.req.query.callback;115 , callback = this.req.query[app.get('jsonp callback name')];116117 // content-type118 this.charset = this.charset || 'utf-8';119 this.set('Content-Type', 'application/json');121120 121 // jsonp122 if (callback && jsonp) {123 this.set('Content-Type', 'text/javascript');124 body = callback.replace(/[^[]\w$.]/g, '') + '(' + body + ');';
463 unmodified lines
modified:test/res.json.js+17 added