2 spaces in request.js
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 · parent 5152823 · Browse files · 2 files·+59 added−59 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+59 added−59 removed
- other:+59 added−59 removed
Provenance
- Commit
0fc4101- Tree
00a45c5- Author
Tj Holowaychuk <tj@vision-media.ca>- Committer
Tj Holowaychuk <tj@vision-media.ca>- Parent
5152823
2 files changed+59 added−59 removed
modified:lib/express/index.js+1 added-1 removed
34 unmodified lines353637383939404142435 unmodified lines34 unmodified lines * @api public */
exports.createServer = function(){ return new Server(Array.prototype.slice.call(arguments)); return new Server(Array.prototype.slice.call(arguments));};
/** * View extensions.5 unmodified linesmodified:lib/express/request.js+58 added-58 removed
7 unmodified lines8 /**9 * Module dependencies.10 */11 12-var http = require('http'),13- utils = require('./utils'),14- mime = require('connect/utils').mime;12+var http = require('http')13+ , utils = require('./utils')14+ , mime = require('connect/utils').mime;15 16 /**17 * Default flash formatters.18 *19 * @type Object20 */21 22 var flashFormatters = exports.flashFormatters = {23- s: function(val){24- return String(val);25- }23+ s: function(val){24+ return String(val);25+ }26 };27 28 /**29 * Return request header or optional default.18 unmodified lines48 * @api public49 */50 51 http.IncomingMessage.prototype.header = function(name, defaultValue){52- return this.headers[name.toLowerCase()] || defaultValue;52+ return this.headers[name.toLowerCase()] || defaultValue;53 };54 55 /**56 * Check if the _Accept_ header is present, and includes the given `type`.25 unmodified lines82 * @api public83 */84 85 http.IncomingMessage.prototype.accepts = function(type){86- var accept = this.header('Accept');87- if (!accept || accept === '*/*') {88- return true;89- } else if (type) {90- // Allow "html" vs "text/html" etc91- if (type.indexOf('/') < 0) {92- type = mime.types['.' + type];93- }94- // Check if we have a direct match95- if (accept.indexOf(type) >= 0) {96- return true;97- // Check if we have type/*98- } else {99- type = type.split('/')[0] + '/*';100- return accept.indexOf(type) >= 0;101- }86+ var accept = this.header('Accept');87+ if (!accept || accept === '*/*') {88+ return true;89+ } else if (type) {90+ // Allow "html" vs "text/html" etc91+ if (type.indexOf('/') < 0) {92+ type = mime.types['.' + type];93+ }94+ // Check if we have a direct match95+ if (accept.indexOf(type) >= 0) {96+ return true;97+ // Check if we have type/*98 } else {103- return false;99+ type = type.split('/')[0] + '/*';100+ return accept.indexOf(type) >= 0;101 }102+ } else {103+ return false;104+ }105 };106 107 /**108 * Return the value of param `name` when present.11 unmodified lines120 * @api public121 */122 123 http.IncomingMessage.prototype.param = function(name){124- // Route params like /user/:id125- if (this.params[name] !== undefined) {126- return this.params[name]; 127- }128- // Query string params129- if (this.query[name] !== undefined) {130- return this.query[name]; 131- }132- // Request body params via connect.bodyDecoder133- if (this.body && this.body[name] !== undefined) {134- return this.body[name];135- }124+ // Route params like /user/:id125+ if (this.params[name] !== undefined) {126+ return this.params[name]; 127+ }128+ // Query string params129+ if (this.query[name] !== undefined) {130+ return this.query[name]; 131+ }132+ // Request body params via connect.bodyDecoder133+ if (this.body && this.body[name] !== undefined) {134+ return this.body[name];135+ }136 };137 138 /**139 * Queue flash `msg` of the given `type`.30 unmodified lines170 * @api public171 */172 173 http.IncomingMessage.prototype.flash = function(type, msg){174- var msgs = this.session.flash = this.session.flash || {};175- if (type && msg) {176- var i = 2,177- args = arguments,178- formatters = this.app.flashFormatters || {};179- formatters.__proto__ = flashFormatters;180- msg = utils.miniMarkdown(utils.htmlEscape(msg));181- msg = msg.replace(/%([a-zA-Z])/g, function(_, format){182- var formatter = formatters[format];183- if (formatter) return formatter(args[i++]);184- });185- return (msgs[type] = msgs[type] || []).push(msg);186- } else if (type) {187- var arr = msgs[type];188- delete msgs[type];189- return arr || [];190- } else {191- this.session.flash = {};192- return msgs;193- }174+ var msgs = this.session.flash = this.session.flash || {};175+ if (type && msg) {176+ var i = 2177+ , args = arguments178+ , formatters = this.app.flashFormatters || {};179+ formatters.__proto__ = flashFormatters;180+ msg = utils.miniMarkdown(utils.htmlEscape(msg));181+ msg = msg.replace(/%([a-zA-Z])/g, function(_, format){182+ var formatter = formatters[format];183+ if (formatter) return formatter(args[i++]);184+ });185+ return (msgs[type] = msgs[type] || []).push(msg);186+ } else if (type) {187+ var arr = msgs[type];188+ delete msgs[type];189+ return arr || [];190+ } else {191+ this.session.flash = {};192+ return msgs;193+ }194 };195 196 // Callback for isXMLHttpRequest / xhr197 198 function isxhr() {199- return this.header('X-Requested-With', '').toLowerCase() === 'xmlhttprequest';199+ return this.header('X-Requested-With', '').toLowerCase() === 'xmlhttprequest';200 }201 202 /**203 * Check if the request was an _XMLHttpRequest_.2 unmodified lines206 * @api public207 */208 209 http.IncomingMessage.prototype.__defineGetter__('isXMLHttpRequest', isxhr);210-http.IncomingMessage.prototype.__defineGetter__('xhr', isxhr);210+http.IncomingMessage.prototype.__defineGetter__('xhr', isxhr);