@tmlmobilidade/utils 20260807.1021.39 → 20260811.1505.45

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.
@@ -29,13 +29,16 @@ export function setValueAtPath(obj, path, value) {
29
29
  }
30
30
  let current = obj;
31
31
  keys.slice(0, -1).forEach((key) => {
32
- if (!(key in current)) {
33
- // If numeric key, initialize as array
34
- current[key] = /^\d+$/.test(key) ? [] : {};
32
+ if (!Object.prototype.hasOwnProperty.call(current, key)) {
33
+ // If numeric key, initialize as array; otherwise use a prototype-less object
34
+ current[key] = /^\d+$/.test(key) ? [] : Object.create(null);
35
35
  }
36
36
  current = current[key];
37
37
  });
38
38
  const lastKey = keys[keys.length - 1];
39
+ if (UNSAFE_KEYS.has(lastKey)) {
40
+ throw new Error(`Unsafe path segment: "${lastKey}"`);
41
+ }
39
42
  current[lastKey] = value;
40
43
  return obj;
41
44
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tmlmobilidade/utils",
3
- "version": "20260807.1021.39",
3
+ "version": "20260811.1505.45",
4
4
  "author": {
5
5
  "email": "iso@tmlmobilidade.pt",
6
6
  "name": "TML-ISO"