Skip to content
Myr

Added `req.ips`

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 04ecf04 · Browse files · 2 files+59 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+59 added−0 removed

  • tests:+40 added−0 removed
  • other:+19 added−0 removed

2 files+59 added−0 removed

modified:lib/request.js+19 added
328 unmodified lines
329 return 'https' == this.protocol;330});331332/**333 * When "trust proxy" is `true`, parse334 * the "X-Forwarded-For" ip address list.335 *336 * @return {Array}337 * @api public338 */339340req.__defineGetter__('ips', function(){341 var trustProxy = this.app.settings['trust proxy']342 , field = this.get('X-Forwarded-For');343344 return trustProxy345 ? field346 ? field.split(/ *, */)347 : []348 : [];349});350351/**352 * Return subdomains as an array.353 *354 * For example "tobi.ferrets.example.com"355 * would provide `["ferrets", "tobi"]`.
60 unmodified lines
added:test/req.ips.js+40 added