@nxtedition/nxt-undici 4.2.24 → 4.2.25

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.
@@ -17,14 +17,14 @@ class Handler extends DecoratorHandler {
17
17
  #headersSent = false
18
18
  #errorSent = false
19
19
 
20
- #abort = null
20
+ #abort
21
21
  #aborted = false
22
- #reason = null
22
+ #reason
23
23
 
24
- #pos = null
25
- #end = null
26
- #etag = null
27
- #error = null
24
+ #pos
25
+ #end
26
+ #etag
27
+ #error
28
28
 
29
29
  constructor(opts, { handler, dispatch }) {
30
30
  super(handler)
@@ -87,7 +87,7 @@ class Handler extends DecoratorHandler {
87
87
  assert(start != null && Number.isFinite(start), 'content-range mismatch')
88
88
  assert(end != null && Number.isFinite(end), 'invalid content-length')
89
89
  assert(
90
- contentLength == null || end == null || contentLength === end + 1 - start,
90
+ contentLength == null || end == null || contentLength === end - start,
91
91
  'content-range mismatch',
92
92
  )
93
93
 
@@ -168,7 +168,7 @@ class Handler extends DecoratorHandler {
168
168
  this.#dispatch(this.#opts, this)
169
169
  } else {
170
170
  assert(Number.isFinite(this.#pos))
171
- assert(this.#end == null || Number.isFinite(this.#end))
171
+ assert(this.#end == null || (Number.isFinite(this.#end) && this.#end > 0))
172
172
 
173
173
  this.#opts = {
174
174
  ...this.#opts,
@@ -177,7 +177,7 @@ class Handler extends DecoratorHandler {
177
177
  ...this.#opts.headers,
178
178
  ...opts?.headers,
179
179
  'if-match': this.#etag,
180
- range: `bytes=${this.#pos}-${this.#end ?? ''}`,
180
+ range: `bytes=${this.#pos}-${this.#end ? this.#end - 1 : ''}`,
181
181
  },
182
182
  }
183
183
 
package/lib/utils.js CHANGED
@@ -10,7 +10,9 @@ export function parseCacheControl(str) {
10
10
  // Parsed accordingly to RFC 9110
11
11
  // https://www.rfc-editor.org/rfc/rfc9110#field.content-range
12
12
  export function parseRangeHeader(range) {
13
- if (range == null || range === '') return { start: 0, end: null, size: null }
13
+ if (range == null || range === '') {
14
+ return { start: 0, end: null, size: null }
15
+ }
14
16
 
15
17
  const m = range ? range.match(/^bytes (\d+)-(\d+)\/(\d+)?$/) : null
16
18
  return m
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxtedition/nxt-undici",
3
- "version": "4.2.24",
3
+ "version": "4.2.25",
4
4
  "license": "MIT",
5
5
  "author": "Robert Nagy <robert.nagy@boffins.se>",
6
6
  "main": "lib/index.js",
@@ -11,16 +11,16 @@
11
11
  "dependencies": {
12
12
  "cache-control-parser": "^2.0.6",
13
13
  "http-errors": "^2.0.0",
14
- "lru-cache": "^11.0.1",
15
- "undici": "^6.19.8"
14
+ "lru-cache": "^11.0.2",
15
+ "undici": "^6.20.1"
16
16
  },
17
17
  "devDependencies": {
18
- "@types/node": "^22.7.4",
18
+ "@types/node": "^22.9.0",
19
19
  "eslint": "^8.0.0",
20
20
  "eslint-config-prettier": "^9.1.0",
21
21
  "eslint-config-standard": "^17.0.0",
22
22
  "eslint-plugin-import": "^2.31.0",
23
- "eslint-plugin-n": "^17.10.3",
23
+ "eslint-plugin-n": "^17.13.1",
24
24
  "eslint-plugin-promise": "^7.1.0",
25
25
  "husky": "^9.1.6",
26
26
  "lint-staged": "^15.2.10",