req.host.js
This file
Path
test/req.host.js
34 lines · 725 bytes · JavaScript
Last changed by
fix `req.host` when no Host is present, return undefinedTJ Holowaychukbefore adoption06ead58
History of this fileTake it
1234567891011121314151617181920212223242526272829303132333435
var express = require('../') , request = require('./support/http') , assert = require('assert');
describe('req', function(){ describe('.host', function(){ it('should return the Host when present', function(done){ var app = express();
app.use(function(req, res){ res.end(req.host); });
request(app) .post('/') .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); }) })})