@uppy/xhr-upload
Advanced tools
Comparing version
# @uppy/xhr-upload | ||
## 4.3.3 | ||
Released: 2025-02-25 | ||
Included in: Uppy v4.13.3 | ||
- @uppy/xhr-upload: fix when responseType is set to JSON (Merlijn Vos / #5651) | ||
## 4.3.1 | ||
@@ -4,0 +11,0 @@ |
@@ -18,3 +18,3 @@ function _classPrivateFieldLooseBase(e, t) { if (!{}.hasOwnProperty.call(e, t)) throw new TypeError("attempted to use private field on non-instance"); return e; } | ||
const packageJson = { | ||
"version": "4.3.2" | ||
"version": "4.3.3" | ||
}; | ||
@@ -161,3 +161,3 @@ import locale from './locale.js'; | ||
try { | ||
var _this$opts$getRespons, _this$opts2, _body2; | ||
var _this$opts$getRespons, _this$opts2, _body3; | ||
const res = await fetcher(url, { | ||
@@ -195,11 +195,16 @@ ...options, | ||
let body = await ((_this$opts$getRespons = (_this$opts2 = this.opts).getResponseData) == null ? void 0 : _this$opts$getRespons.call(_this$opts2, res)); | ||
try { | ||
if (res.responseType === 'json') { | ||
var _body; | ||
(_body = body) != null ? _body : body = JSON.parse(res.responseText); | ||
} catch (cause) { | ||
throw new Error('@uppy/xhr-upload expects a JSON response (with a `url` property). To parse non-JSON responses, use `getResponseData` to turn your response into JSON.', { | ||
cause | ||
}); | ||
(_body = body) != null ? _body : body = res.response; | ||
} else { | ||
try { | ||
var _body2; | ||
(_body2 = body) != null ? _body2 : body = JSON.parse(res.responseText); | ||
} catch (cause) { | ||
throw new Error('@uppy/xhr-upload expects a JSON response (with a `url` property). To parse non-JSON responses, use `getResponseData` to turn your response into JSON.', { | ||
cause | ||
}); | ||
} | ||
} | ||
const uploadURL = typeof ((_body2 = body) == null ? void 0 : _body2.url) === 'string' ? body.url : undefined; | ||
const uploadURL = typeof ((_body3 = body) == null ? void 0 : _body3.url) === 'string' ? body.url : undefined; | ||
for (const { | ||
@@ -206,0 +211,0 @@ id |
{ | ||
"name": "@uppy/xhr-upload", | ||
"description": "Plain and simple classic HTML multipart form uploads with Uppy, as well as uploads using the HTTP PUT method.", | ||
"version": "4.3.2", | ||
"version": "4.3.3", | ||
"license": "MIT", | ||
@@ -28,11 +28,11 @@ "main": "lib/index.js", | ||
"@uppy/companion-client": "^4.4.1", | ||
"@uppy/utils": "^6.1.1" | ||
"@uppy/utils": "^6.1.2" | ||
}, | ||
"devDependencies": { | ||
"nock": "^13.1.0", | ||
"vitest": "^1.2.1" | ||
"vitest": "^1.6.1" | ||
}, | ||
"peerDependencies": { | ||
"@uppy/core": "^4.4.1" | ||
"@uppy/core": "^4.4.2" | ||
} | ||
} |
@@ -238,9 +238,14 @@ import { BasePlugin } from '@uppy/core' | ||
let body = await this.opts.getResponseData?.(res) | ||
try { | ||
body ??= JSON.parse(res.responseText) as B | ||
} catch (cause) { | ||
throw new Error( | ||
'@uppy/xhr-upload expects a JSON response (with a `url` property). To parse non-JSON responses, use `getResponseData` to turn your response into JSON.', | ||
{ cause }, | ||
) | ||
if (res.responseType === 'json') { | ||
body ??= res.response | ||
} else { | ||
try { | ||
body ??= JSON.parse(res.responseText) as B | ||
} catch (cause) { | ||
throw new Error( | ||
'@uppy/xhr-upload expects a JSON response (with a `url` property). To parse non-JSON responses, use `getResponseData` to turn your response into JSON.', | ||
{ cause }, | ||
) | ||
} | ||
} | ||
@@ -247,0 +252,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
91994
0.83%1144
0.79%Updated