Skip to content
Myr

Added `req.subdomains`

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 e2f43df · Browse files · 2 files+60 added−0 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+60 added−0 removed

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

2 files+60 added−0 removed

modified:lib/request.js+17 added
310 unmodified lines
311 return this.connection.encrypted;312});313314/**315 * Return subdomains as an array.316 *317 * For example "tobi.ferrets.example.com"318 * would provide `["ferrets", "tobi"]`.319 *320 * @return {Array}321 * @api public322 */323324req.__defineGetter__('subdomains', function(){325 return this.get('Host')326 .split('.')327 .slice(0, -2)328 .reverse();329});330331/**332 * Short-hand for `require('url').parse(req.url).pathname`.333 *334 * @return {String}335 * @api public
43 unmodified lines
added:test/req.subdomains.js+43 added