nock 13.5.2 → 13.5.4

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.
Files changed (2) hide show
  1. package/lib/interceptor.js +10 -13
  2. package/package.json +2 -2
@@ -198,10 +198,16 @@ module.exports = class Interceptor {
198
198
  if (!fs) {
199
199
  throw new Error('No fs')
200
200
  }
201
- const readStream = fs.createReadStream(filePath)
202
- readStream.pause()
203
201
  this.filePath = filePath
204
- return this.reply(statusCode, readStream, headers)
202
+ return this.reply(
203
+ statusCode,
204
+ () => {
205
+ const readStream = fs.createReadStream(filePath)
206
+ readStream.pause()
207
+ return readStream
208
+ },
209
+ headers,
210
+ )
205
211
  }
206
212
 
207
213
  // Also match request headers
@@ -453,15 +459,6 @@ module.exports = class Interceptor {
453
459
  markConsumed() {
454
460
  this.interceptionCounter++
455
461
 
456
- if (
457
- (this.scope.shouldPersist() || this.counter > 0) &&
458
- this.interceptionCounter > 1 &&
459
- this.filePath
460
- ) {
461
- this.body = fs.createReadStream(this.filePath)
462
- this.body.pause()
463
- }
464
-
465
462
  remove(this)
466
463
 
467
464
  if (!this.scope.shouldPersist() && this.counter < 1) {
@@ -510,7 +507,7 @@ module.exports = class Interceptor {
510
507
  strFormattingFn = common.percentDecode
511
508
  }
512
509
 
513
- if (queries instanceof URLSearchParams) {
510
+ if (queries instanceof URLSearchParams || typeof queries === 'string') {
514
511
  // Normalize the data into the shape that is matched against.
515
512
  // Duplicate keys are handled by combining the values into an array.
516
513
  queries = querystring.parse(queries.toString())
package/package.json CHANGED
@@ -7,7 +7,7 @@
7
7
  "testing",
8
8
  "isolation"
9
9
  ],
10
- "version": "13.5.2",
10
+ "version": "13.5.4",
11
11
  "author": "Pedro Teixeira <pedro.teixeira@gmail.com>",
12
12
  "repository": {
13
13
  "type": "git",
@@ -45,7 +45,7 @@
45
45
  "mocha": "^9.1.3",
46
46
  "npm-run-all": "^4.1.5",
47
47
  "nyc": "^15.0.0",
48
- "prettier": "3.1.0",
48
+ "prettier": "3.2.4",
49
49
  "proxyquire": "^2.1.0",
50
50
  "rimraf": "^3.0.0",
51
51
  "semantic-release": "^22.0.5",