Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Socket
Sign inDemoInstall

nock

Package Overview
Dependencies
Maintainers
3
Versions
431
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nock - npm Package Compare versions

Comparing version 11.9.0 to 11.9.1

9

index.js

@@ -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,

4

lib/back.js
'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[]

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc