fix: should get subdomains from hostname instead (#809)
This helps avoid dealing with the port in this.host
This commit is contained in:
parent
4c665cc2ef
commit
27caff3d59
2 changed files with 5 additions and 5 deletions
|
@ -418,9 +418,9 @@ module.exports = {
|
||||||
|
|
||||||
get subdomains() {
|
get subdomains() {
|
||||||
var offset = this.app.subdomainOffset;
|
var offset = this.app.subdomainOffset;
|
||||||
var host = this.host || '';
|
var hostname = this.hostname;
|
||||||
if (net.isIP(host)) return [];
|
if (net.isIP(hostname)) return [];
|
||||||
return host
|
return hostname
|
||||||
.split('.')
|
.split('.')
|
||||||
.reverse()
|
.reverse()
|
||||||
.slice(offset);
|
.slice(offset);
|
||||||
|
|
|
@ -19,9 +19,9 @@ describe('req.subdomains', function(){
|
||||||
req.subdomains.should.eql([]);
|
req.subdomains.should.eql([]);
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should check if the host is an ip address', function(){
|
it('should check if the host is an ip address, even with a port', function(){
|
||||||
var req = request();
|
var req = request();
|
||||||
req.header.host = '127.0.0.1';
|
req.header.host = '127.0.0.1:3000';
|
||||||
req.subdomains.should.eql([]);
|
req.subdomains.should.eql([]);
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue