sanity checks for JS fetch errors

Signed-off-by: Andy Miller <rhuk@mac.com>
This commit is contained in:
Andy Miller
2025-09-03 18:32:58 -06:00
parent 377da15ec1
commit 7135c34005
4 changed files with 17 additions and 11 deletions

View File

@@ -99,7 +99,7 @@ export default class Updates {
if (!this.payload.resources.total) { return this; }
[plugins, themes].forEach(function(resources, index) {
if (!resources || Array.isArray(resources)) { return; }
if (!resources || Array.isArray(resources) || typeof resources !== 'object') { return; }
let length = Object.keys(resources).length;
let type = map[index];

View File

@@ -12,7 +12,9 @@ let request = function(url, options = {}, callback = () => true) {
let data = new FormData();
options.body = Object.assign({ 'admin-nonce': config.admin_nonce }, options.body || {});
Object.keys(options.body).map((key) => data.append(key, options.body[key]));
if (options.body && typeof options.body === 'object') {
Object.keys(options.body).map((key) => data.append(key, options.body[key]));
}
options.body = data;
}

View File

@@ -73,7 +73,7 @@ export function userFeedback(response) {
break;
}
if (settings) {
if (settings && typeof settings === 'object' && settings !== null) {
backup = Object.assign({}, toastr.options);
Object.keys(settings).forEach((key) => { toastr.options[key] = settings[key]; });
}