Skip to content
Myr

move "subdomain offset" defaulting to config

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 5beb1c4 · Browse files · 2 files+11 added−12 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+11 added−12 removed

  • other:+11 added−12 removed

2 files+11 added−12 removed

modified:lib/application.js+1 added
46 unmodified lines
47app.defaultConfiguration = function(){48 // default settings49 this.enable('x-powered-by');50 this.set('env', process.env.NODE_ENV || 'development');51 this.set('subdomain offset', 2);52 debug('booting in %s mode', this.get('env'));5354 // implicit middleware55 this.use(connect.query());
479 unmodified lines
modified:lib/request.js+10 added-12 removed
27 unmodified lines
28 * Examples:29 *30 * req.get('Content-Type');31 * // => "text/plain"32 * 32 *33 * req.get('content-type');34 * // => "text/plain"35 * 35 *36 * req.get('Something');37 * // => undefined38 *39 * Aliased as `req.header()`.40 *41 * @param {String} name42 * @return {String} 42 * @return {String}43 * @api public44 */4546req.get = 46req.get =47req.header = function(name){48 switch (name = name.toLowerCase()) {49 case 'referer':50 case 'referrer':
15 unmodified lines
66 * or an array `["json", "html", "text/plain"]`. When a list67 * or array is given the _best_ match, if any is returned.68 *69 * Examples:70 * 70 *71 * // Accept: text/html72 * req.accepts('html');73 * // => "html"74 *
185 unmodified lines
260 return defaultValue;261};262263/**264 * Check if the incoming request contains the "Content-Type" 264 * Check if the incoming request contains the "Content-Type"265 * header field, and it contains the give mime `type`.266 *267 * Examples:268 *
1 unmodified line
270 * req.is('html');271 * req.is('text/html');272 * req.is('text/*');273 * // => true274 * 274 *275 * // When Content-Type is application/json276 * req.is('json');277 * req.is('application/json');278 * req.is('application/*');279 * // => true280 * 280 *281 * req.is('html');282 * // => false283 * 283 *284 * @param {String} type285 * @return {Boolean}286 * @api public287 */
14 unmodified lines
302};303304/**305 * Return the protocol string "http" or "https"306 * when requested with TLS. When the "trust proxy" 306 * when requested with TLS. When the "trust proxy"307 * setting is enabled the "X-Forwarded-Proto" header308 * field will be trusted. If you're running behind309 * a reverse proxy that supplies https for you this310 * may be enabled.
103 unmodified lines
414 */415416req.__defineGetter__('subdomains', function(){417 var offset = this.app.get('subdomain offset');418 if (offset == null) offset = 2;419418 return this.get('Host').split('.').reverse().slice(offset);419});420421/**
69 unmodified lines