Skip to content
Myr

Fix req.host for IPv6 literals

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

fixes #2102

authored by Douglas Christopher Wilson · committed by Douglas Christopher Wilson · parent d581592 · Browse files · 3 files+51 added−1 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+51 added−1 removed

  • tests:+39 added−0 removed
  • other:+12 added−1 removed

3 files+51 added−1 removed

modified:lib/request.js+7 added-1 removed
474 unmodified lines
475 var trustProxy = this.app.get('trust proxy');476 var host = trustProxy && this.get('X-Forwarded-Host');477 host = host || this.get('Host');478 if (!host) return;479 return host.split(':')[0];479 var offset = host[0] === '['480 ? host.indexOf(']') + 1481 : 0;482 var index = host.indexOf(':', offset);483 return ~index484 ? host.substring(0, index)485 : host;486});487488/**489 * Check if the request is fresh, aka
46 unmodified lines
modified:test/req.host.js+39 added
modified:History.md+5 added
13.5.x2=====34 * fix `req.host` for IPv6 literals563.5.2 / 2014-04-247==================89 * update connect to 2.14.5
1273 unmodified lines