Comparing version 2.0.0 to 2.0.1
2.0.1 / 2017-01-22 | ||
================== | ||
* fix: Only restore the http/https request when used. | ||
2.0.0 / 2016-07-31 | ||
@@ -3,0 +8,0 @@ ================== |
@@ -204,4 +204,2 @@ /**! | ||
getAgent(http).__sourceRequest = getAgent(http).request; | ||
getAgent(https).__sourceRequest = getAgent(https).request; | ||
@@ -257,2 +255,3 @@ function matchURL(options, params) { | ||
exports.http.request = function(url, data, headers, delay) { | ||
backupOriginalRequest(http); | ||
return _request.call(this, http, url, data, headers, delay); | ||
@@ -272,5 +271,12 @@ }; | ||
exports.https.request = function(url, data, headers, delay) { | ||
backupOriginalRequest(https); | ||
return _request.call(this, https, url, data, headers, delay); | ||
}; | ||
function backupOriginalRequest(mod) { | ||
if (!getAgent(mod).__sourceRequest) { | ||
getAgent(mod).__sourceRequest = getAgent(mod).request; | ||
} | ||
} | ||
function _request(mod, url, data, headers, delay) { | ||
@@ -363,2 +369,3 @@ headers = headers || {}; | ||
exports.http.requestError = function(url, reqError, resError, delay) { | ||
backupOriginalRequest(http); | ||
_requestError.call(this, http, url, reqError, resError, delay); | ||
@@ -375,2 +382,3 @@ }; | ||
exports.https.requestError = function(url, reqError, resError, delay) { | ||
backupOriginalRequest(https); | ||
_requestError.call(this, https, url, reqError, resError, delay); | ||
@@ -454,4 +462,10 @@ }; | ||
exports.restore = function() { | ||
getAgent(http).request = getAgent(http).__sourceRequest; | ||
getAgent(https).request = getAgent(https).__sourceRequest; | ||
if (getAgent(http).__sourceRequest) { | ||
getAgent(http).request = getAgent(http).__sourceRequest; | ||
getAgent(http).__sourceRequest = null; | ||
} | ||
if (getAgent(https).__sourceRequest) { | ||
getAgent(https).request = getAgent(https).__sourceRequest; | ||
getAgent(https).__sourceRequest = null; | ||
} | ||
muk.restore(); | ||
@@ -458,0 +472,0 @@ return this; |
{ | ||
"name": "mm", | ||
"version": "2.0.0", | ||
"version": "2.0.1", | ||
"description": "mock mate, mock http request, fs access and so on.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
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
24806
487