req.ips.js
This file
Path
test/req.ips.js
36 lines · 851 bytes · JavaScript
Last changed by
reverse req.ips arrayTJ Holowaychukbefore adoption54c3d5c
History of this fileTake it
Added `req.ips`TJ Holowaychukbefore adoptiondd468fb
lines 1–16why, one step back12var express = require('../')3 , request = require('./support/http');45describe('req', function(){6 describe('.ips', function(){7 describe('when X-Forwarded-For is present', function(){8 it('should return an array of the specified addresses', function(done){9 var app = express();1011 app.use(function(req, res, next){12 res.send(req.ips);13 });1415 request(app)16 .get('/')reverse req.ips arrayTJ Holowaychukbefore adoption54c3d5c
lines 17–18why, one step back17 .set('X-Forwarded-For', 'client, p1, p2')18 .expect('["p2","p1","client"]', done);Added `req.ips`TJ Holowaychukbefore adoptiondd468fb
lines 19–36why, one step back19 })20 })2122 describe('when X-Forwarded-For is not present', function(){23 it('should return []', function(done){24 var app = express();2526 app.use(function(req, res, next){27 res.send(req.ips);28 });2930 request(app)31 .get('/')32 .expect('[]', done);33 })34 })35 })36})