Comparing version 11.9.0 to 11.9.1
@@ -32,3 +32,10 @@ 'use strict' | ||
enableNetConnect, | ||
cleanAll: removeAll, | ||
// TODO-12.x Historically `nock.cleanAll()` has returned the nock global. | ||
// The other global methods do not do this, so it's not clear this was | ||
// deliberate or is even helpful. This shim is included for backward | ||
// compatibility and should be replaced with an alias to `removeAll()`. | ||
cleanAll() { | ||
removeAll() | ||
return module.exports | ||
}, | ||
abortPendingRequests, | ||
@@ -35,0 +42,0 @@ load, |
'use strict' | ||
const assert = require('assert') | ||
const _ = require('lodash') | ||
const recorder = require('./recorder') | ||
@@ -63,3 +64,4 @@ const { | ||
if (typeof fixtureName !== 'string') { | ||
// TODO-12.x: Replace with `typeof fixtureName === 'string'`. | ||
if (!_.isString(fixtureName)) { | ||
throw new Error('Parameter fixtureName must be a string') | ||
@@ -66,0 +68,0 @@ } |
@@ -177,3 +177,4 @@ 'use strict' | ||
const contentEncoding = headers['content-encoding'] | ||
return typeof contentEncoding === 'string' && contentEncoding !== '' | ||
// TODO-12.x: Replace with `typeof contentEncoding === 'string'`. | ||
return _.isString(contentEncoding) && contentEncoding !== '' | ||
} | ||
@@ -367,3 +368,4 @@ | ||
if (typeof fieldNameToDelete !== 'string') { | ||
// TODO-12.x: Replace with `typeof fieldNameToDelete !== 'string'`. | ||
if (!_.isString(fieldNameToDelete)) { | ||
throw Error('field name must be a string') | ||
@@ -449,3 +451,4 @@ } | ||
break | ||
case typeof value === 'string': | ||
// TODO-12.x: Replace with `typeof value === 'string'`. | ||
case _.isString(value): | ||
if (stringFormattingFn) { | ||
@@ -452,0 +455,0 @@ value = stringFormattingFn(value) |
@@ -11,2 +11,3 @@ 'use strict' | ||
const http = require('http') | ||
const _ = require('lodash') | ||
const debug = require('debug')('nock.intercept') | ||
@@ -53,13 +54,9 @@ const globalEmitter = require('./global_emitter') | ||
* nock.enableNetConnect(/(google|amazon)/); | ||
* @example | ||
* // Enables real requests for url that includes google | ||
* nock.enableNetConnect(host => host.includes('google')); | ||
*/ | ||
function enableNetConnect(matcher) { | ||
if (typeof matcher === 'string') { | ||
// TODO-12.x: Replace with `typeof matcher === 'string'`. | ||
if (_.isString(matcher)) { | ||
allowNetConnect = new RegExp(matcher) | ||
} else if (matcher instanceof RegExp) { | ||
allowNetConnect = matcher | ||
} else if (typeof matcher === 'function') { | ||
allowNetConnect = { test: matcher } | ||
} else { | ||
@@ -66,0 +63,0 @@ allowNetConnect = /.*/ |
@@ -10,3 +10,3 @@ { | ||
], | ||
"version": "11.9.0", | ||
"version": "11.9.1", | ||
"author": "Pedro Teixeira <pedro.teixeira@gmail.com>", | ||
@@ -21,3 +21,3 @@ "repository": { | ||
"engines": { | ||
"node": ">= 10.13" | ||
"node": ">= 8.0" | ||
}, | ||
@@ -30,3 +30,3 @@ "main": "./index.js", | ||
"lodash": "^4.17.13", | ||
"mkdirp": "^1.0.0", | ||
"mkdirp": "^0.5.0", | ||
"propagate": "^2.0.0" | ||
@@ -47,3 +47,3 @@ }, | ||
"eslint-plugin-standard": "^4.0.0", | ||
"got": "^10.5.2", | ||
"got": "^9.6.0", | ||
"@sinonjs/fake-timers": "^6.0.0", | ||
@@ -50,0 +50,0 @@ "mocha": "^7.0.1", |
@@ -1157,3 +1157,3 @@ # Nock | ||
You could allow real HTTP requests for certain host names by providing a string or a regular expression for the hostname, or a function that accepts the hostname and returns true or false: | ||
You could allow real HTTP requests for certain host names by providing a string or a regular expression for the hostname: | ||
@@ -1167,7 +1167,2 @@ ```js | ||
// Or a Function | ||
nock.enableNetConnect( | ||
host => host.includes('amazon.com') || host.includes('github.com') | ||
) | ||
http.get('http://www.amazon.com/') | ||
@@ -1174,0 +1169,0 @@ http.get('http://github.com/') |
@@ -24,5 +24,3 @@ // TypeScript Version: 3.5 | ||
function disableNetConnect(): void | ||
function enableNetConnect( | ||
matcher?: string | RegExp | ((host: string) => boolean) | ||
): void | ||
function enableNetConnect(matcher?: string | RegExp): void | ||
function load(path: string): Scope[] | ||
@@ -29,0 +27,0 @@ function loadDefs(path: string): Definition[] |
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
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
170169
3401
0
1611
+ Addedminimist@1.2.8(transitive)
+ Addedmkdirp@0.5.6(transitive)
- Removedmkdirp@1.0.4(transitive)
Updatedmkdirp@^0.5.0