Skip to content

Commit

Permalink
Changed: dont reverse req.ips
Browse files Browse the repository at this point in the history
parse them as-is. im impartial about
the ordering but this spares some CPU. if you
prefer the other way let me know
  • Loading branch information
tj committed May 30, 2012
1 parent e3cbac2 commit b694ba2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ req.__defineGetter__('secure', function(){
* the "X-Forwarded-For" ip address list.
*
* For example if the value were "client, proxy1, proxy2"
* you would receive the array `["proxy2", "proxy1", "client"]`
* you would receive the array `["client", "proxy1", "proxy2"]`
* where "proxy2" is the furthest down-stream.
*
* @return {Array}
Expand All @@ -341,7 +341,7 @@ req.__defineGetter__('ips', function(){
var trustProxy = this.app.enabled('trust proxy');
var val = this.get('X-Forwarded-For');
return trustProxy && val
? val.split(/ *, */).reverse()
? val.split(/ *, */)
: [];
});

Expand Down
2 changes: 1 addition & 1 deletion test/req.ips.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe('req', function(){
request(app)
.get('/')
.set('X-Forwarded-For', 'client, p1, p2')
.expect('["p2","p1","client"]', done);
.expect('["client","p1","p2"]', done);
})
})

Expand Down

0 comments on commit b694ba2

Please sign in to comment.