@nxtedition/nxt-undici 2.0.5 → 2.0.7

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/index.js +5 -5
  2. package/package.json +1 -1
package/lib/index.js CHANGED
@@ -225,7 +225,6 @@ export async function request(url, opts) {
225
225
  dispatch = (opts, handler) => dispatcher.dispatch(opts, handler)
226
226
  dispatch = dispatchers.catch(dispatch)
227
227
  dispatch = dispatchers.requestBodyFactory(dispatch)
228
- dispatch = dispatchers.abort(dispatch)
229
228
  dispatch = dispatchers.log(dispatch)
230
229
  dispatch = dispatchers.requestId(dispatch)
231
230
  dispatch = dispatchers.responseRetry(dispatch)
@@ -332,10 +331,11 @@ export async function request(url, opts) {
332
331
  await res.dump()
333
332
  } else if (res.statusCode >= 400) {
334
333
  // TODO (fix): Limit the size of the body?
335
- const data =
336
- res.headers['content-type']?.toLowerCase() === 'application/json'
337
- ? await res.json()
338
- : await res.text()
334
+ const data = /^application\/json$/i.test(res.headers['content-type'])
335
+ ? await res.json()
336
+ : /^text-.+/i.test(res.headers['content-type'])
337
+ ? await res.text()
338
+ : await res.dump()
339
339
  throw createError(res.statusCode, { headers, data })
340
340
  }
341
341
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxtedition/nxt-undici",
3
- "version": "2.0.5",
3
+ "version": "2.0.7",
4
4
  "license": "MIT",
5
5
  "author": "Robert Nagy <robert.nagy@boffins.se>",
6
6
  "main": "lib/index.js",