Socket
Socket
Sign inDemoInstall

nock

Package Overview
Dependencies
Maintainers
4
Versions
430
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 13.0.8 to 13.0.9

29

lib/common.js

@@ -676,2 +676,30 @@ 'use strict'

/**
* Check if the Client Request has been cancelled.
*
* Until Node 14 is the minimum, we need to look at both flags to see if the request has been cancelled.
* The two flags have the same purpose, but the Node maintainers are migrating from `abort(ed)` to
* `destroy(ed)` terminology, to be more consistent with `stream.Writable`.
* In Node 14.x+, Calling `abort()` will set both `aborted` and `destroyed` to true, however,
* calling `destroy()` will only set `destroyed` to true.
* Falling back on checking if the socket is destroyed to cover the case of Node <14.x where
* `destroy()` is called, but `destroyed` is undefined.
*
* Node Client Request history:
* - `request.abort()`: Added in: v0.3.8, Deprecated since: v14.1.0, v13.14.0
* - `request.aborted`: Added in: v0.11.14, Became a boolean instead of a timestamp: v11.0.0, Not deprecated (yet)
* - `request.destroy()`: Added in: v0.3.0
* - `request.destroyed`: Added in: v14.1.0, v13.14.0
*
* @param {ClientRequest} req
* @returns {boolean}
*/
function isRequestDestroyed(req) {
return !!(
req.destroyed === true ||
req.aborted ||
(req.socket && req.socket.destroyed)
)
}
module.exports = {

@@ -690,2 +718,3 @@ contentEncoding,

isPlainObject,
isRequestDestroyed,
isStream,

@@ -692,0 +721,0 @@ isUtf8Representable,

6

lib/intercepted_request_router.js

@@ -106,4 +106,3 @@ 'use strict'

// Until Node 14 is the minimum, we need to look at both flags to see if the request has been cancelled.
if (req.destroyed || req.aborted) {
if (common.isRequestDestroyed(req)) {
return

@@ -254,4 +253,3 @@ }

// Until Node 14 is the minimum, we need to look at both flags to see if the request has been cancelled.
if (!req.destroyed && !req.aborted && !playbackStarted) {
if (!common.isRequestDestroyed(req) && !playbackStarted) {
this.startPlayback()

@@ -258,0 +256,0 @@ }

@@ -296,3 +296,3 @@ 'use strict'

function respond() {
if (req.aborted) {
if (common.isRequestDestroyed(req)) {
return

@@ -322,3 +322,3 @@ }

common.setImmediate(() => {
if (!req.aborted) {
if (!common.isRequestDestroyed(req)) {
start()

@@ -325,0 +325,0 @@ }

@@ -10,3 +10,3 @@ {

],
"version": "13.0.8",
"version": "13.0.9",
"author": "Pedro Teixeira <pedro.teixeira@gmail.com>",

@@ -44,3 +44,3 @@ "repository": {

"eslint-plugin-promise": "^4.1.1",
"eslint-plugin-standard": "^4.0.0",
"eslint-plugin-standard": "^5.0.0",
"form-data": "^3.0.0",

@@ -51,3 +51,3 @@ "got": "^11.3.0",

"nyc": "^15.0.0",
"prettier": "2.0.5",
"prettier": "2.2.1",
"proxyquire": "^2.1.0",

@@ -60,3 +60,3 @@ "request": "^2.83.0",

"superagent": "^6.1.0",
"tap": "14.6.1"
"typescript": "^4.2.2"
},

@@ -70,16 +70,5 @@ "scripts": {

"lint:ts": "dtslint types",
"test": "run-s test:mocha test:tap",
"test:coverage": "tap --coverage-report=html && open coverage/lcov-report/index.html",
"test:mocha": "nyc mocha $(grep -lr '^\\s*it(' tests)",
"test:tap": "tap --100 --coverage --coverage-report=text ./tests/test_*.js"
"test": "nyc mocha tests",
"test:coverage": "open coverage/lcov-report/index.html"
},
"nyc": {
"reporter": [
"lcov",
"text-summary"
],
"exclude": [
"tests/"
]
},
"license": "MIT",

@@ -86,0 +75,0 @@ "files": [

@@ -1216,9 +1216,8 @@ # Nock

const recordedTimestamp = recordedBodyResult[1]
return body.replace(/(timestamp):([0-9]+)/g, function (
match,
key,
value
) {
return key + ':' + recordedTimestamp
})
return body.replace(
/(timestamp):([0-9]+)/g,
function (match, key, value) {
return key + ':' + recordedTimestamp
}
)
} else {

@@ -1225,0 +1224,0 @@ return body

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