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
12345678910111213141516171819202122232425262728293031323334353637
var express = require('../') , request = require('./support/http');
describe('req', function(){ describe('.ips', function(){ describe('when X-Forwarded-For is present', function(){ it('should return an array of the specified addresses', function(done){ var app = express();
app.use(function(req, res, next){ res.send(req.ips); });
request(app) .get('/') .set('X-Forwarded-For', 'client, p1, p2') .expect('["p2","p1","client"]', done); }) })
describe('when X-Forwarded-For is not present', function(){ it('should return []', function(done){ var app = express();
app.use(function(req, res, next){ res.send(req.ips); });
request(app) .get('/') .expect('[]', done); }) }) })})