@nxtedition/nxt-undici 2.0.23 → 2.0.24

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.
@@ -4,9 +4,9 @@ import { findHeader } from '../utils.js'
4
4
  class Handler {
5
5
  constructor(opts, { handler, md5, length }) {
6
6
  this.handler = handler
7
- this.md5 = md5
7
+ this.md5 = opts.md5 ? md5 : null
8
8
  this.length = length
9
- this.hasher = opts.md5 && this.md5 ? crypto.createHash('md5') : null
9
+ this.hasher = this.md5 ? crypto.createHash('md5') : null
10
10
  this.pos = 0
11
11
  this.abort = null
12
12
  }
@@ -29,7 +29,7 @@ class Handler {
29
29
  }
30
30
 
31
31
  onRequestSent() {
32
- const hash = this.hasher?.digest('base64')
32
+ const hash = this.hasher?.digest('base64') ?? null
33
33
 
34
34
  if (this.length != null && this.pos !== Number(this.length)) {
35
35
  this.abort(
@@ -28,9 +28,9 @@ class Handler {
28
28
  }
29
29
 
30
30
  onHeaders(statusCode, rawHeaders, resume, statusMessage, headers) {
31
- this.md5 = findHeader(rawHeaders, 'content-md5')
31
+ this.md5 = this.opts.md5 ? findHeader(rawHeaders, 'content-md5') : null
32
32
  this.length = findHeader(rawHeaders, 'content-length')
33
- this.hasher = this.opts.md5 && this.md5 != null ? crypto.createHash('md5') : null
33
+ this.hasher = this.md5 != null ? crypto.createHash('md5') : null
34
34
 
35
35
  return this.handler.onHeaders(statusCode, rawHeaders, resume, statusMessage, headers)
36
36
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxtedition/nxt-undici",
3
- "version": "2.0.23",
3
+ "version": "2.0.24",
4
4
  "license": "MIT",
5
5
  "author": "Robert Nagy <robert.nagy@boffins.se>",
6
6
  "main": "lib/index.js",