@nxtedition/nxt-undici 2.0.5 → 2.0.6

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 -4
  2. package/package.json +1 -1
package/lib/index.js CHANGED
@@ -332,10 +332,11 @@ export async function request(url, opts) {
332
332
  await res.dump()
333
333
  } else if (res.statusCode >= 400) {
334
334
  // 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()
335
+ const data = /^application\/json$/i.test(res.headers['content-type'])
336
+ ? await res.json()
337
+ : /^text-.+/i.test(res.headers['content-type'])
338
+ ? await res.text()
339
+ : await res.dump()
339
340
  throw createError(res.statusCode, { headers, data })
340
341
  }
341
342
 
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.6",
4
4
  "license": "MIT",
5
5
  "author": "Robert Nagy <robert.nagy@boffins.se>",
6
6
  "main": "lib/index.js",