nock 13.2.1 → 13.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/common.js +10 -4
- package/lib/intercepted_request_router.js +4 -1
- package/lib/interceptor.js +8 -1
- package/lib/recorder.js +1 -1
- package/package.json +6 -6
- package/CHANGELOG.md +0 -6
package/lib/common.js
CHANGED
|
@@ -194,7 +194,7 @@ function isJSONContent(headers) {
|
|
|
194
194
|
*
|
|
195
195
|
* Duplicates throw an error.
|
|
196
196
|
*/
|
|
197
|
-
function headersFieldNamesToLowerCase(headers) {
|
|
197
|
+
function headersFieldNamesToLowerCase(headers, throwOnDuplicate) {
|
|
198
198
|
if (!isPlainObject(headers)) {
|
|
199
199
|
throw Error('Headers must be provided as an object')
|
|
200
200
|
}
|
|
@@ -203,9 +203,15 @@ function headersFieldNamesToLowerCase(headers) {
|
|
|
203
203
|
Object.entries(headers).forEach(([fieldName, fieldValue]) => {
|
|
204
204
|
const key = fieldName.toLowerCase()
|
|
205
205
|
if (lowerCaseHeaders[key] !== undefined) {
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
206
|
+
if (throwOnDuplicate) {
|
|
207
|
+
throw Error(
|
|
208
|
+
`Failed to convert header keys to lower case due to field name conflict: ${key}`
|
|
209
|
+
)
|
|
210
|
+
} else {
|
|
211
|
+
debug(
|
|
212
|
+
`Duplicate header provided in request: ${key}. Only the last value can be matched.`
|
|
213
|
+
)
|
|
214
|
+
}
|
|
209
215
|
}
|
|
210
216
|
lowerCaseHeaders[key] = fieldValue
|
|
211
217
|
})
|
|
@@ -40,7 +40,10 @@ class InterceptedRequestRouter {
|
|
|
40
40
|
// affecting the user so we use a clone of the object.
|
|
41
41
|
...options,
|
|
42
42
|
// We use lower-case header field names throughout Nock.
|
|
43
|
-
headers: common.headersFieldNamesToLowerCase(
|
|
43
|
+
headers: common.headersFieldNamesToLowerCase(
|
|
44
|
+
options.headers || {},
|
|
45
|
+
false
|
|
46
|
+
),
|
|
44
47
|
}
|
|
45
48
|
this.interceptors = interceptors
|
|
46
49
|
|
package/lib/interceptor.js
CHANGED
|
@@ -66,7 +66,8 @@ module.exports = class Interceptor {
|
|
|
66
66
|
|
|
67
67
|
// We use lower-case header field names throughout Nock.
|
|
68
68
|
this.reqheaders = common.headersFieldNamesToLowerCase(
|
|
69
|
-
scope.scopeOptions.reqheaders || {}
|
|
69
|
+
scope.scopeOptions.reqheaders || {},
|
|
70
|
+
true
|
|
70
71
|
)
|
|
71
72
|
this.badheaders = common.headersFieldsArrayToLowerCase(
|
|
72
73
|
scope.scopeOptions.badheaders || []
|
|
@@ -412,6 +413,12 @@ module.exports = class Interceptor {
|
|
|
412
413
|
}
|
|
413
414
|
|
|
414
415
|
matchHostName(options) {
|
|
416
|
+
const { basePath } = this.scope
|
|
417
|
+
|
|
418
|
+
if (basePath instanceof RegExp) {
|
|
419
|
+
return basePath.test(options.hostname)
|
|
420
|
+
}
|
|
421
|
+
|
|
415
422
|
return options.hostname === this.scope.urlParts.hostname
|
|
416
423
|
}
|
|
417
424
|
|
package/lib/recorder.js
CHANGED
|
@@ -168,7 +168,7 @@ let currentRecordingId = 0
|
|
|
168
168
|
const defaultRecordOptions = {
|
|
169
169
|
dont_print: false,
|
|
170
170
|
enable_reqheaders_recording: false,
|
|
171
|
-
logging: console.log,
|
|
171
|
+
logging: console.log, // eslint-disable-line no-console
|
|
172
172
|
output_objects: false,
|
|
173
173
|
use_separator: true,
|
|
174
174
|
}
|
package/package.json
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
"testing",
|
|
8
8
|
"isolation"
|
|
9
9
|
],
|
|
10
|
-
"version": "13.2.
|
|
10
|
+
"version": "13.2.2",
|
|
11
11
|
"author": "Pedro Teixeira <pedro.teixeira@gmail.com>",
|
|
12
12
|
"repository": {
|
|
13
13
|
"type": "git",
|
|
@@ -37,19 +37,19 @@
|
|
|
37
37
|
"eslint-config-prettier": "^8.1.0",
|
|
38
38
|
"eslint-config-standard": "^16.0.2",
|
|
39
39
|
"eslint-plugin-import": "^2.16.0",
|
|
40
|
-
"eslint-plugin-mocha": "^
|
|
40
|
+
"eslint-plugin-mocha": "^10.0.3",
|
|
41
41
|
"eslint-plugin-node": "^11.0.0",
|
|
42
|
-
"eslint-plugin-promise": "^
|
|
42
|
+
"eslint-plugin-promise": "^6.0.0",
|
|
43
43
|
"eslint-plugin-standard": "^5.0.0",
|
|
44
44
|
"form-data": "^4.0.0",
|
|
45
45
|
"got": "^11.3.0",
|
|
46
|
-
"mocha": "^
|
|
46
|
+
"mocha": "^9.1.3",
|
|
47
47
|
"npm-run-all": "^4.1.5",
|
|
48
48
|
"nyc": "^15.0.0",
|
|
49
|
-
"prettier": "2.
|
|
49
|
+
"prettier": "2.5.1",
|
|
50
50
|
"proxyquire": "^2.1.0",
|
|
51
51
|
"rimraf": "^3.0.0",
|
|
52
|
-
"semantic-release": "^
|
|
52
|
+
"semantic-release": "^18.0.1",
|
|
53
53
|
"sinon": "^12.0.1",
|
|
54
54
|
"sinon-chai": "^3.7.0",
|
|
55
55
|
"typescript": "^4.2.2"
|
package/CHANGELOG.md
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
# Changelog
|
|
2
|
-
|
|
3
|
-
Nock’s changelog can be found directly in the [GitHub release notes](https://github.com/nock/nock/releases).
|
|
4
|
-
These are automatically created by [semantic-release](https://github.com/semantic-release/semantic-release) based on their [commit message conventions](https://semantic-release.gitbook.io/semantic-release#commit-message-format).
|
|
5
|
-
|
|
6
|
-
Migration guides are available for major versions in the [migration guides directory](https://github.com/nock/nock/tree/main/migration_guides).
|