Comparing version 0.0.7 to 0.0.8
@@ -0,1 +1,9 @@ | ||
## 0.0.8 | ||
Enhancement: | ||
- Added support for proxies with `underscores_in_headers off;` | ||
- Handling hyphen as delimiter - ex: `X-FORWARDED-FOR` instead of `X_FORWARDED_FOR` | ||
- Up version node.js in .travis.yml | ||
## 0.0.7 | ||
@@ -2,0 +10,0 @@ |
28
index.js
@@ -84,11 +84,23 @@ | ||
_me.get_headers_attribute = function (headers, key) { | ||
var value = null; | ||
if (key.toLowerCase() in headers) { | ||
value = headers[key.toLowerCase()]; | ||
} else { | ||
if (key in headers) { | ||
value = headers[key]; | ||
} | ||
key_upper = key.toUpperCase(); | ||
if (key_upper in headers) { | ||
return headers[key_upper]; | ||
} | ||
return value; | ||
key_lower = key.toLowerCase(); | ||
if (key_lower in headers) { | ||
return headers[key_lower]; | ||
} | ||
alt_key_lower = key_lower.replace(/_/g, '-'); | ||
if (alt_key_lower in headers) { | ||
return headers[alt_key_lower]; | ||
} | ||
alt_key_upper = alt_key_lower.toUpperCase() | ||
if (alt_key_upper in headers) { | ||
return headers[alt_key_upper]; | ||
} | ||
return null; | ||
} | ||
@@ -95,0 +107,0 @@ |
{ | ||
"name": "ipware", | ||
"version": "0.0.7", | ||
"version": "0.0.8", | ||
"description": "Returns the real IP address of users in Node.js", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -39,5 +39,5 @@ Node IPware | ||
// `get_ip` also adds two fields to your request object | ||
// 1. `clientIP`, 2. `clientIpRoutable` | ||
// 1. `clientIp`, 2. `clientIpRoutable` | ||
// Where: | ||
// `clientIP` holds the client's IP address | ||
// `clientIp` holds the client's IP address | ||
// 'clientIpRoutable` is `true` if user's IP is `public`. (externally route-able) | ||
@@ -44,0 +44,0 @@ // is `false` if user's IP is `private`. (not externally route-able) |
@@ -218,5 +218,2 @@ var get_ip = require('..')().get_ip, | ||
describe('get_ip(): IPV4: Test 1.0.0.0/8 blocks', function() { | ||
@@ -241,1 +238,10 @@ it('test_1_0_0_0_block', function() { | ||
}); | ||
describe('get_ip(): IPV4: X-FORWARDED-FOR', function() { | ||
it('test_http_x_forwarded_for_precedence-hyphenated', function() { | ||
var request = {headers: {'X-FORWARDED-FOR': '80.10.1.10'}}; | ||
get_ip(request); | ||
assert.equal(request.clientIp, '80.10.1.10'); | ||
assert.equal(request.clientIpRoutable, true); | ||
}); | ||
}); |
@@ -212,3 +212,2 @@ var get_ip = require('..')().get_ip, | ||
describe('get_ip(): IPV6: http_x_real_ip', function() { | ||
@@ -244,1 +243,10 @@ it('test_fallback_on_request.connection.remoteAddress.private', function() { | ||
}); | ||
describe('get_ip(): IPV6: X-FORWARDED-FOR', function() { | ||
it('test_http_x_forwarded_for_precedence-hyphenated', function() { | ||
var request = {headers: {'X-FORWARDED-FOR': '74dC::02bA'}}; | ||
get_ip(request); | ||
assert.equal(request.clientIp, '74dC::02bA'); | ||
assert.equal(request.clientIpRoutable, true); | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
33136
662