node-mocks-http
Advanced tools
Comparing version 1.10.0 to 1.10.1
@@ -0,1 +1,8 @@ | ||
v 1.10.1 | ||
------- | ||
- Fix support for req.hostname [Issue #231][231]. | ||
[231]: https://github.com/howardabrams/node-mocks-http/issues/231 | ||
v 1.10.0 | ||
@@ -2,0 +9,0 @@ ------- |
@@ -481,3 +481,3 @@ 'use strict'; | ||
/** | ||
@@ -493,3 +493,3 @@ * Function: send | ||
mockRequest.send = function(data) { | ||
if(Buffer.isBuffer(data)){ | ||
@@ -508,16 +508,15 @@ this.emit('data', data); | ||
* | ||
* Hostname is the main domain of the host without the subdomains and port. | ||
* If Hostname is not set explicitly, then derive it from the Host header without port information | ||
* | ||
*/ | ||
mockRequest.hostname = (function() { | ||
if (!mockRequest.headers.host) { | ||
return ''; | ||
} | ||
if (!mockRequest.hostname) { | ||
mockRequest.hostname = (function() { | ||
if (!mockRequest.headers.host) { | ||
return ''; | ||
} | ||
var offset = 2; | ||
var hostname = mockRequest.headers.host.split(':')[0].split('.'); | ||
var start = hostname.length - offset; | ||
var end = hostname.length; | ||
return hostname.slice(start, end).join('.'); | ||
}()); | ||
var hostname = mockRequest.headers.host.split(':')[0].split('.'); | ||
return hostname.join('.'); | ||
}()); | ||
} | ||
@@ -540,3 +539,3 @@ /** | ||
}()); | ||
return mockRequest; | ||
@@ -543,0 +542,0 @@ } |
@@ -5,3 +5,3 @@ { | ||
"description": "Mock 'http' objects for testing Express routing functions", | ||
"version": "1.10.0", | ||
"version": "1.10.1", | ||
"homepage": "https://github.com/howardabrams/node-mocks-http", | ||
@@ -8,0 +8,0 @@ "bugs": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
80213
1885