Update checked-in dependencies

This commit is contained in:
github-actions[bot] 2021-07-27 16:54:30 +00:00
parent 35f1961385
commit 17223bdff7
20 changed files with 1756 additions and 646 deletions

40
node_modules/nock/lib/scope.js generated vendored
View file

@ -9,7 +9,6 @@ const assert = require('assert')
const url = require('url')
const debug = require('debug')('nock.scope')
const { EventEmitter } = require('events')
const util = require('util')
const Interceptor = require('./interceptor')
let fs
@ -40,7 +39,6 @@ class Scope extends EventEmitter {
this.transformPathFunction = null
this.transformRequestBodyFunction = null
this.matchHeaders = []
this.logger = debug
this.scopeOptions = options || {}
this.urlParts = {}
this._persist = false
@ -51,13 +49,18 @@ class Scope extends EventEmitter {
this.port = null
this._defaultReplyHeaders = []
let logNamespace = String(basePath)
if (!(basePath instanceof RegExp)) {
this.urlParts = url.parse(basePath)
this.port =
this.urlParts.port || (this.urlParts.protocol === 'http:' ? 80 : 443)
this.basePathname = this.urlParts.pathname.replace(/\/$/, '')
this.basePath = `${this.urlParts.protocol}//${this.urlParts.hostname}:${this.port}`
logNamespace = this.urlParts.host
}
this.logger = debug.extend(logNamespace)
}
add(key, interceptor) {
@ -170,7 +173,7 @@ class Scope extends EventEmitter {
const filteringArguments = arguments
if (arguments[0] instanceof RegExp) {
return function(candidate) {
return function (candidate) {
/* istanbul ignore if */
if (typeof candidate !== 'string') {
// Given the way nock is written, it seems like `candidate` will always
@ -219,11 +222,6 @@ class Scope extends EventEmitter {
return this
}
log(newLogger) {
this.logger = newLogger
return this
}
persist(flag = true) {
if (typeof flag !== 'boolean') {
throw new Error('Invalid arguments: argument should be a boolean')
@ -306,17 +304,10 @@ function tryJsonParse(string) {
}
}
// Use a noop deprecate util instead calling emitWarning directly so we get --no-deprecation and single warning behavior for free.
const emitAsteriskDeprecation = util.deprecate(
() => {},
'Skipping body matching using "*" is deprecated. Set the definition body to undefined instead.',
'NOCK1579'
)
function define(nockDefs) {
const scopes = []
nockDefs.forEach(function(nockDef) {
nockDefs.forEach(function (nockDef) {
const nscope = getScopeFromDefinition(nockDef)
const npath = nockDef.path
if (!nockDef.method) {
@ -335,23 +326,12 @@ function define(nockDefs) {
options.reqheaders = reqheaders
options.badheaders = badheaders
let { body } = nockDef
if (body === '*') {
// In previous versions, it was impossible to NOT filter on request bodies. This special value
// is sniffed out for users manipulating the definitions and not wanting to match on the
// request body. For newer versions, users should remove the `body` key or set to `undefined`
// to achieve the same affect. Maintaining legacy behavior for now.
emitAsteriskDeprecation()
body = undefined
}
// Response is not always JSON as it could be a string or binary data or
// even an array of binary buffers (e.g. when content is encoded).
let response
if (!nockDef.response) {
response = ''
// TODO: Rename `responseIsBinary` to `reponseIsUtf8Representable`.
// TODO: Rename `responseIsBinary` to `responseIsUtf8Representable`.
} else if (nockDef.responseIsBinary) {
response = Buffer.from(nockDef.response, 'hex')
} else {
@ -375,7 +355,9 @@ function define(nockDefs) {
}
})
scope.intercept(npath, method, body).reply(status, response, rawHeaders)
scope
.intercept(npath, method, nockDef.body)
.reply(status, response, rawHeaders)
scopes.push(scope)
})