Compare commits

...

7 Commits
3.2.3 ... 3.2.4

Author SHA1 Message Date
TJ Holowaychuk
f976625281 Release 3.2.4 2013-05-09 09:17:48 -07:00
TJ Holowaychuk
028d9d8a0c Merge pull request #1598 from colynb/patch-1
the file is hosts not vhosts
2013-05-09 09:12:54 -07:00
TJ Holowaychuk
8559c0e2a4 fix req.subdomains when no Host is present 2013-05-09 09:10:52 -07:00
TJ Holowaychuk
06ead58240 fix req.host when no Host is present, return undefined 2013-05-09 09:06:11 -07:00
TJ Holowaychuk
28ca1b5221 add req.host tests 2013-05-09 09:03:52 -07:00
TJ Holowaychuk
6d872e6693 remove qs dep 2013-05-07 07:58:54 -07:00
colynb
69453ff889 the file is hosts not vhosts 2013-05-01 16:27:29 -07:00
7 changed files with 61 additions and 7 deletions

View File

@@ -1,4 +1,10 @@
3.2.4 / 2013-05-09
==================
* fix `req.subdomains` when no Host is present
* fix `req.host` when no Host is present, return undefined
3.2.3 / 2013-05-07
==================

View File

@@ -1,4 +1,3 @@
/**
* Module dependencies.
*/
@@ -6,7 +5,7 @@
var express = require('../..');
/*
edit /etc/vhosts:
edit /etc/hosts:
127.0.0.1 foo.example.com
127.0.0.1 bar.example.com

View File

@@ -20,7 +20,7 @@ exports = module.exports = createApplication;
* Framework version.
*/
exports.version = '3.2.3';
exports.version = '3.2.4';
/**
* Expose mime.

View File

@@ -445,7 +445,7 @@ req.__defineGetter__('auth', function(){
req.__defineGetter__('subdomains', function(){
var offset = this.app.get('subdomain offset');
return this.get('Host')
return (this.host || '')
.split('.')
.reverse()
.slice(offset);
@@ -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];
});

View File

@@ -1,7 +1,7 @@
{
"name": "express",
"description": "Sinatra inspired web development framework",
"version": "3.2.3",
"version": "3.2.4",
"author": "TJ Holowaychuk <tj@vision-media.ca>",
"contributors": [
{
@@ -32,8 +32,7 @@
"methods": "0.0.1",
"send": "0.1.0",
"cookie-signature": "1.0.1",
"debug": "*",
"qs": "0.6.4"
"debug": "*"
},
"devDependencies": {
"ejs": "*",

34
test/req.host.js Normal file
View File

@@ -0,0 +1,34 @@
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);
})
})
})

View File

@@ -34,6 +34,21 @@ describe('req', function(){
})
})
describe('with no host', function(){
it('should return an empty array', function(done){
var app = express();
app.use(function(req, res){
req.headers.host = null;
res.send(req.subdomains);
});
request(app)
.get('/')
.expect('[]', done);
})
})
describe('when subdomain offset is set', function(){
describe('when subdomain offset is zero', function(){
it('should return an array with the whole domain', function(done){