mirror of
https://github.com/d0zingcat/cors-anywhere.git
synced 2026-05-13 15:09:25 +00:00
Monkey-patch nock, add Node v8 to test matrix
This commit is contained in:
@@ -4,6 +4,7 @@ node_js:
|
||||
- 4
|
||||
- 6
|
||||
- 7
|
||||
- 8
|
||||
script:
|
||||
- npm run lint
|
||||
- npm run test
|
||||
|
||||
@@ -1,4 +1,26 @@
|
||||
var nock = require('nock');
|
||||
if (parseInt(process.versions.node, 10) >= 8) {
|
||||
// See DEP0066 at https://nodejs.org/api/deprecations.html.
|
||||
// _headers and _headerNames have been removed from Node v8, which causes
|
||||
// nock <= 9.0.13 to fail. The snippet below monkey-patches the library, see
|
||||
// https://github.com/node-nock/nock/pull/929/commits/f6369d0edd2a172024124f
|
||||
// for the equivalent logic without proxies.
|
||||
Object.defineProperty(require('http').ClientRequest.prototype, '_headers', {
|
||||
get: function() {
|
||||
var request = this;
|
||||
// eslint-disable-next-line no-undef
|
||||
return new Proxy(request.getHeaders(), {
|
||||
set: function(target, property, value) {
|
||||
request.setHeader(property, value);
|
||||
return true;
|
||||
},
|
||||
});
|
||||
},
|
||||
set: function() {
|
||||
// Ignore.
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
nock.enableNetConnect('127.0.0.1');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user