@yuneta/gobj-js 7.26.6 → 7.26.8

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.
@@ -4064,6 +4064,10 @@ function strrchr_split(str, char) {
4064
4064
  function kw_delete(gobj, kw, path) {
4065
4065
  if (gobj && !is_gobj(gobj)) log_error(`GObj bad instanceof`);
4066
4066
  const prefix = gobj ? gobj_short_name(gobj) + ": " : "";
4067
+ if (!is_string(path)) {
4068
+ log_error(`${prefix}kw_delete(): path must be a string: ${String(path)}`);
4069
+ return -1;
4070
+ }
4067
4071
  let [path_, k] = strrchr_split(path, "`");
4068
4072
  let v = kw;
4069
4073
  if (!empty_string(k)) {
@@ -4430,6 +4434,10 @@ function kw_set_dict_value(gobj, kw, path, value) {
4430
4434
  log_error("kw is not an object");
4431
4435
  return -1;
4432
4436
  }
4437
+ if (!is_string(path)) {
4438
+ log_error(`${gobj ? gobj_short_name(gobj) + ": " : ""}kw_set_dict_value(): path must be a string: ${String(path)}`);
4439
+ return -1;
4440
+ }
4433
4441
  let ss = path.split("`");
4434
4442
  let len = ss.length;
4435
4443
  for (let i = 0; i < len; i++) {
@@ -4464,9 +4472,14 @@ function kw_set_subdict_value(gobj, kw, path, key, value) {
4464
4472
  log_error("kw is not an object");
4465
4473
  return -1;
4466
4474
  }
4467
- let subdict = kw_get_dict(gobj, kw, path, {}, kw_flag_t.KW_CREATE);
4475
+ let subdict = kw_find_path(gobj, kw, path, false);
4476
+ if (subdict === void 0) {
4477
+ if (!is_string(path)) return -1;
4478
+ subdict = {};
4479
+ if (kw_set_dict_value(gobj, kw, path, subdict) < 0) return -1;
4480
+ }
4468
4481
  if (!is_object(subdict)) {
4469
- log_error("subdict is not an object");
4482
+ log_error(`subdict is not an object: '${path}'`);
4470
4483
  return -1;
4471
4484
  }
4472
4485
  set_own_key(subdict, key, value);
@@ -5213,6 +5226,10 @@ function jdb_update(jdb, topic_name, path, kw) {
5213
5226
  trace_msg(kw);
5214
5227
  return null;
5215
5228
  }
5229
+ if (!is_string(path)) {
5230
+ log_error(`jdb_update: path must be a string: ${String(path)}`);
5231
+ return null;
5232
+ }
5216
5233
  let ids = path.split("`");
5217
5234
  let id;
5218
5235
  let v = topic;
@@ -5247,6 +5264,10 @@ function jdb_delete(jdb, topic_name, path, kw) {
5247
5264
  trace_msg(kw);
5248
5265
  return null;
5249
5266
  }
5267
+ if (!is_string(path)) {
5268
+ log_error(`jdb_delete: path must be a string: ${String(path)}`);
5269
+ return null;
5270
+ }
5250
5271
  let ids = path.split("`");
5251
5272
  let id;
5252
5273
  let v = topic;