Comparing version 13.3.3 to 13.3.4
@@ -52,3 +52,3 @@ 'use strict' | ||
'Ex:\n' + | ||
"\trequire(nock).back.fixtures = '/path/to/fixtures/'" | ||
"\trequire(nock).back.fixtures = '/path/to/fixtures/'", | ||
) | ||
@@ -304,4 +304,4 @@ } | ||
[].concat(...pending), | ||
fixture | ||
) | ||
fixture, | ||
), | ||
) | ||
@@ -308,0 +308,0 @@ } |
@@ -84,3 +84,3 @@ 'use strict' | ||
throw new Error( | ||
`Module's request already overridden for ${moduleName} protocol.` | ||
`Module's request already overridden for ${moduleName} protocol.`, | ||
) | ||
@@ -130,3 +130,3 @@ } | ||
debug('- restored request for', proto) | ||
} | ||
}, | ||
) | ||
@@ -211,7 +211,7 @@ requestOverrides = {} | ||
throw Error( | ||
`Failed to convert header keys to lower case due to field name conflict: ${key}` | ||
`Failed to convert header keys to lower case due to field name conflict: ${key}`, | ||
) | ||
} else { | ||
debug( | ||
`Duplicate header provided in request: ${key}. Only the last value can be matched.` | ||
`Duplicate header provided in request: ${key}. Only the last value can be matched.`, | ||
) | ||
@@ -250,3 +250,3 @@ } | ||
throw new Error( | ||
`Raw headers must be provided as an array with an even number of items. [fieldName, value, ...]` | ||
`Raw headers must be provided as an array with an even number of items. [fieldName, value, ...]`, | ||
) | ||
@@ -267,3 +267,3 @@ } | ||
throw new Error( | ||
`Headers must be provided as an array of raw values, a Map, or a plain Object. ${headers}` | ||
`Headers must be provided as an array of raw values, a Map, or a plain Object. ${headers}`, | ||
) | ||
@@ -608,3 +608,3 @@ } | ||
const allKeys = Array.from( | ||
new Set(Object.keys(expected).concat(Object.keys(actual))) | ||
new Set(Object.keys(expected).concat(Object.keys(actual))), | ||
) | ||
@@ -611,0 +611,0 @@ |
@@ -154,3 +154,3 @@ 'use strict' | ||
for (const { key, interceptors, allowUnmocked } of Object.values( | ||
allInterceptors | ||
allInterceptors, | ||
)) { | ||
@@ -189,3 +189,3 @@ for (const interceptor of interceptors) { | ||
interceptors.length > 1 ? 's' : '' | ||
})` | ||
})`, | ||
) | ||
@@ -248,3 +248,3 @@ return interceptors | ||
this.emit('error', error) | ||
}.bind(this) | ||
}.bind(this), | ||
) | ||
@@ -278,3 +278,3 @@ } | ||
throw Error( | ||
'Creating a ClientRequest with empty `options` is not supported in Nock' | ||
'Creating a ClientRequest with empty `options` is not supported in Nock', | ||
) | ||
@@ -315,6 +315,6 @@ } | ||
options.host, | ||
options.path | ||
options.path, | ||
) | ||
this.emit('error', error) | ||
}.bind(this) | ||
}.bind(this), | ||
) | ||
@@ -356,3 +356,3 @@ } | ||
const nestedInterceptors = Object.values(allInterceptors).map( | ||
i => i.interceptors | ||
i => i.interceptors, | ||
) | ||
@@ -398,3 +398,3 @@ return [].concat(...nestedInterceptors).map(i => i.scope) | ||
throw Error( | ||
'Making a request with empty `options` is not supported in Nock' | ||
'Making a request with empty `options` is not supported in Nock', | ||
) | ||
@@ -412,6 +412,6 @@ } | ||
const matches = interceptors.some(interceptor => | ||
interceptor.matchOrigin(options) | ||
interceptor.matchOrigin(options), | ||
) | ||
const allowUnmocked = interceptors.some( | ||
interceptor => interceptor.options.allowUnmocked | ||
interceptor => interceptor.options.allowUnmocked, | ||
) | ||
@@ -418,0 +418,0 @@ |
@@ -45,3 +45,3 @@ 'use strict' | ||
options.headers || {}, | ||
false | ||
false, | ||
), | ||
@@ -93,3 +93,3 @@ } | ||
'authorization', | ||
`Basic ${Buffer.from(options.auth).toString('base64')}` | ||
`Basic ${Buffer.from(options.auth).toString('base64')}`, | ||
) | ||
@@ -302,7 +302,7 @@ } | ||
const requestBodyString = requestBodyBuffer.toString( | ||
requestBodyIsUtf8Representable ? 'utf8' : 'hex' | ||
requestBodyIsUtf8Representable ? 'utf8' : 'hex', | ||
) | ||
const matchedInterceptor = interceptors.find(i => | ||
i.match(req, options, requestBodyString) | ||
i.match(req, options, requestBodyString), | ||
) | ||
@@ -312,3 +312,3 @@ | ||
matchedInterceptor.scope.logger( | ||
'interceptor identified, starting mocking' | ||
'interceptor identified, starting mocking', | ||
) | ||
@@ -336,3 +336,3 @@ | ||
const allowUnmocked = interceptors.some( | ||
i => i.matchHostName(options) && i.options.allowUnmocked | ||
i => i.matchHostName(options) && i.options.allowUnmocked, | ||
) | ||
@@ -339,0 +339,0 @@ |
@@ -42,3 +42,3 @@ 'use strict' | ||
throw Error( | ||
`Non-wildcard URL path strings must begin with a slash (otherwise they won't match anything) (got: ${uri})` | ||
`Non-wildcard URL path strings must begin with a slash (otherwise they won't match anything) (got: ${uri})`, | ||
) | ||
@@ -49,3 +49,3 @@ } | ||
throw new Error( | ||
'The "method" parameter is required for an intercept call.' | ||
'The "method" parameter is required for an intercept call.', | ||
) | ||
@@ -72,6 +72,6 @@ } | ||
scope.scopeOptions.reqheaders || {}, | ||
true | ||
true, | ||
) | ||
this.badheaders = common.headersFieldsArrayToLowerCase( | ||
scope.scopeOptions.badheaders || [] | ||
scope.scopeOptions.badheaders || [], | ||
) | ||
@@ -124,3 +124,3 @@ | ||
throw Error( | ||
'Invalid arguments. When providing a function for the first argument, .reply does not accept other arguments.' | ||
'Invalid arguments. When providing a function for the first argument, .reply does not accept other arguments.', | ||
) | ||
@@ -159,3 +159,3 @@ } | ||
this.headers = common.headersArrayToObject( | ||
this.rawHeaders.concat(this.scope._defaultReplyHeaders) | ||
this.rawHeaders.concat(this.scope._defaultReplyHeaders), | ||
) | ||
@@ -244,3 +244,3 @@ | ||
header, | ||
reqHeader | ||
reqHeader, | ||
) | ||
@@ -256,3 +256,3 @@ return false | ||
stringify(options), | ||
stringify(body) | ||
stringify(body), | ||
) | ||
@@ -269,3 +269,3 @@ } | ||
this.scope.logger( | ||
`Method did not match. Request ${method} Interceptor ${this.method}` | ||
`Method did not match. Request ${method} Interceptor ${this.method}`, | ||
) | ||
@@ -297,3 +297,3 @@ return false | ||
const reqHeadersMatch = Object.keys(this.reqheaders).every(key => | ||
this.reqheaderMatches(options, key) | ||
this.reqheaderMatches(options, key), | ||
) | ||
@@ -311,3 +311,3 @@ | ||
this.scope.logger( | ||
'matching failed because Scope.conditionally() did not validate' | ||
'matching failed because Scope.conditionally() did not validate', | ||
) | ||
@@ -318,3 +318,3 @@ return false | ||
const badHeaders = this.badheaders.filter( | ||
header => header in options.headers | ||
header => header in options.headers, | ||
) | ||
@@ -336,3 +336,3 @@ | ||
this.scope.logger( | ||
matchQueries ? 'query matching succeeded' : 'query matching failed' | ||
matchQueries ? 'query matching succeeded' : 'query matching failed', | ||
) | ||
@@ -384,3 +384,3 @@ | ||
'\n', | ||
body | ||
body, | ||
) | ||
@@ -387,0 +387,0 @@ } |
@@ -32,3 +32,3 @@ 'use strict' | ||
throw Error( | ||
'The array returned from the .reply callback contains too many values' | ||
'The array returned from the .reply callback contains too many values', | ||
) | ||
@@ -261,3 +261,3 @@ } | ||
response.rawHeaders.push( | ||
...selectDefaultHeaders(response.rawHeaders, defaultHeaders) | ||
...selectDefaultHeaders(response.rawHeaders, defaultHeaders), | ||
) | ||
@@ -264,0 +264,0 @@ |
@@ -71,3 +71,3 @@ 'use strict' | ||
dataChunks, | ||
res.headers | ||
res.headers, | ||
) | ||
@@ -124,3 +124,3 @@ options.path = req.path | ||
queryObj[key], | ||
common.percentEncode | ||
common.percentEncode, | ||
) | ||
@@ -373,3 +373,3 @@ encodedQueryObj[formattedPair[0]] = formattedPair[1] | ||
currentRecordingId, | ||
'restoring all the overridden http/https properties' | ||
'restoring all the overridden http/https properties', | ||
) | ||
@@ -376,0 +376,0 @@ |
@@ -38,3 +38,3 @@ 'use strict' | ||
throw new TypeError( | ||
`Protocol '${u.protocol}' not recognized. This commonly occurs when a hostname and port are included without a protocol, producing a URL that is valid but confusing, and probably not what you want.` | ||
`Protocol '${u.protocol}' not recognized. This commonly occurs when a hostname and port are included without a protocol, producing a URL that is valid but confusing, and probably not what you want.`, | ||
) | ||
@@ -116,3 +116,3 @@ } | ||
this.scopeOptions, | ||
this.urlParts.hostname | ||
this.urlParts.hostname, | ||
) | ||
@@ -140,3 +140,3 @@ } | ||
requestBody, | ||
interceptorOptions | ||
interceptorOptions, | ||
) | ||
@@ -188,3 +188,3 @@ | ||
return !persistedAndUsed && !optional | ||
}) | ||
}), | ||
) | ||
@@ -211,3 +211,3 @@ } | ||
this.isDone(), | ||
`Mocks not yet satisfied:\n${this.pendingMocks().join('\n')}` | ||
`Mocks not yet satisfied:\n${this.pendingMocks().join('\n')}`, | ||
) | ||
@@ -228,3 +228,3 @@ } | ||
throw Error( | ||
`Nock internal assertion failed: typeof candidate is ${typeof candidate}. If you encounter this error, please report it as a bug.` | ||
`Nock internal assertion failed: typeof candidate is ${typeof candidate}. If you encounter this error, please report it as a bug.`, | ||
) | ||
@@ -243,3 +243,3 @@ } | ||
throw new Error( | ||
'Invalid arguments: filtering path should be a function or a regular expression' | ||
'Invalid arguments: filtering path should be a function or a regular expression', | ||
) | ||
@@ -254,3 +254,3 @@ } | ||
throw new Error( | ||
'Invalid arguments: filtering request body should be a function or a regular expression' | ||
'Invalid arguments: filtering request body should be a function or a regular expression', | ||
) | ||
@@ -337,3 +337,3 @@ } | ||
throw new Error( | ||
'Mismatched port numbers in scope and port properties of nock definition.' | ||
'Mismatched port numbers in scope and port properties of nock definition.', | ||
) | ||
@@ -340,0 +340,0 @@ } |
@@ -77,3 +77,3 @@ 'use strict' | ||
return Buffer.from( | ||
(Math.random() * 10000 + Date.now()).toString() | ||
(Math.random() * 10000 + Date.now()).toString(), | ||
).toString('base64') | ||
@@ -80,0 +80,0 @@ } |
@@ -10,3 +10,3 @@ { | ||
], | ||
"version": "13.3.3", | ||
"version": "13.3.4", | ||
"author": "Pedro Teixeira <pedro.teixeira@gmail.com>", | ||
@@ -38,3 +38,3 @@ "repository": { | ||
"eslint": "^8.8.0", | ||
"eslint-config-prettier": "^8.1.0", | ||
"eslint-config-prettier": "^9.0.0", | ||
"eslint-config-standard": "^17.0.0-0", | ||
@@ -50,3 +50,3 @@ "eslint-plugin-import": "^2.16.0", | ||
"nyc": "^15.0.0", | ||
"prettier": "2.8.8", | ||
"prettier": "3.0.3", | ||
"proxyquire": "^2.1.0", | ||
@@ -53,0 +53,0 @@ "rimraf": "^3.0.0", |
@@ -1145,3 +1145,3 @@ # Nock | ||
nock.enableNetConnect( | ||
host => host.includes('amazon.com') || host.includes('github.com') | ||
host => host.includes('amazon.com') || host.includes('github.com'), | ||
) | ||
@@ -1252,3 +1252,3 @@ | ||
return key + ':' + recordedTimestamp | ||
} | ||
}, | ||
) | ||
@@ -1472,3 +1472,3 @@ } else { | ||
/(timestamp):([0-9]+)/g, | ||
(match, key, value) => `${key}:${recordedTimestamp}` | ||
(match, key, value) => `${key}:${recordedTimestamp}`, | ||
) | ||
@@ -1475,0 +1475,0 @@ } else { |
@@ -11,4 +11,4 @@ // TypeScript Version: 3.5 | ||
declare function nock( | ||
basePath: string | RegExp | Url, | ||
options?: nock.Options | ||
basePath: string | RegExp | Url | URL, | ||
options?: nock.Options, | ||
): nock.Scope | ||
@@ -26,3 +26,3 @@ | ||
function enableNetConnect( | ||
matcher?: string | RegExp | ((host: string) => boolean) | ||
matcher?: string | RegExp | ((host: string) => boolean), | ||
): void | ||
@@ -42,3 +42,3 @@ function load(path: string): Scope[] | ||
requestBody?: RequestBodyMatcher, | ||
interceptorOptions?: Options | ||
interceptorOptions?: Options, | ||
) => Interceptor | ||
@@ -82,3 +82,3 @@ | ||
res: IncomingMessage, | ||
body: string | Buffer | ||
body: string | Buffer, | ||
) => string | string[] | ||
@@ -117,3 +117,3 @@ type ReplyHeaderValue = string | string[] | ReplyHeaderFunction | ||
requestBody?: RequestBodyMatcher, | ||
options?: Options | ||
options?: Options, | ||
) => Interceptor | ||
@@ -145,3 +145,3 @@ | ||
| URLSearchParams | ||
| { (parsedObj: ParsedUrlQuery): boolean } | ||
| { (parsedObj: ParsedUrlQuery): boolean }, | ||
): this | ||
@@ -160,5 +160,5 @@ | ||
err: NodeJS.ErrnoException | null, | ||
result: ReplyFnResult | ||
) => void | ||
) => void | ||
result: ReplyFnResult, | ||
) => void, | ||
) => void, | ||
): Scope | ||
@@ -169,4 +169,4 @@ reply( | ||
uri: string, | ||
body: Body | ||
) => ReplyFnResult | Promise<ReplyFnResult> | ||
body: Body, | ||
) => ReplyFnResult | Promise<ReplyFnResult>, | ||
): Scope | ||
@@ -179,5 +179,8 @@ reply( | ||
body: Body, | ||
callback: (err: NodeJS.ErrnoException | null, result: ReplyBody) => void | ||
callback: ( | ||
err: NodeJS.ErrnoException | null, | ||
result: ReplyBody, | ||
) => void, | ||
) => void, | ||
headers?: ReplyHeaders | ||
headers?: ReplyHeaders, | ||
): Scope | ||
@@ -189,5 +192,5 @@ reply( | ||
uri: string, | ||
body: Body | ||
body: Body, | ||
) => ReplyBody | Promise<ReplyBody>, | ||
headers?: ReplyHeaders | ||
headers?: ReplyHeaders, | ||
): Scope | ||
@@ -201,3 +204,3 @@ reply(responseCode?: StatusCode, body?: Body, headers?: ReplyHeaders): Scope | ||
fileName: string, | ||
headers?: ReplyHeaders | ||
headers?: ReplyHeaders, | ||
): Scope | ||
@@ -265,5 +268,8 @@ | ||
options: BackOptions, | ||
nockedFn: (nockDone: () => void) => void | ||
nockedFn: (nockDone: () => void) => void, | ||
): void | ||
(fixtureName: string, options?: BackOptions): Promise<{ | ||
( | ||
fixtureName: string, | ||
options?: BackOptions, | ||
): Promise<{ | ||
nockDone: () => void | ||
@@ -270,0 +276,0 @@ context: BackContext |
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
180074
3515