fix req.host when no Host is present, return undefined

Esse commit está contido em:
TJ Holowaychuk
2013-05-09 09:06:11 -07:00
commit 06ead58240
2 arquivos alterados com 14 adições e 0 exclusões
+1
Ver Arquivo
@@ -473,6 +473,7 @@ req.__defineGetter__('host', function(){
var trustProxy = this.app.get('trust proxy');
var host = trustProxy && this.get('X-Forwarded-Host');
host = host || this.get('Host');
if (!host) return;
return host.split(':')[0];
});
+13
Ver Arquivo
@@ -17,5 +17,18 @@ describe('req', function(){
.set('Host', 'example.com')
.expect('example.com', done);
})
it('should return undefined otherwise', function(done){
var app = express();
app.use(function(req, res){
req.headers.host = null;
res.end(String(req.host));
});
request(app)
.post('/')
.expect('undefined', done);
})
})
})