Skip to content
Myr

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 file

Take it

add req.host testsTJ Holowaychukbefore adoption28ca1b5

lines 1–19why, one step back
1
2var express = require('../')3 , request = require('./support/http')4 , assert = require('assert');56describe('req', function(){7 describe('.host', function(){8 it('should return the Host when present', function(done){9 var app = express();1011 app.use(function(req, res){12 res.end(req.host);13 });1415 request(app)16 .post('/')17 .set('Host', 'example.com')18 .expect('example.com', done);19 })

fix `req.host` when no Host is present, return undefinedTJ Holowaychukbefore adoption06ead58

lines 20–32why, one step back
20
21 it('should return undefined otherwise', function(done){22 var app = express();2324 app.use(function(req, res){25 req.headers.host = null;26 res.end(String(req.host));27 });2829 request(app)30 .post('/')31 .expect('undefined', done);32 })

add req.host testsTJ Holowaychukbefore adoption28ca1b5

lines 33–34why, one step back
33 })
34})