check_prototype_pollution(key);
const is_array = /^\d+$/.test(keys[i + 1]);
- const exists = key in current;
+ const exists = Object.hasOwn(current, key);
const inner = current[key];
if (exists && is_array !== Array.isArray(inner)) {
import {
BINARY_FORM_CONTENT_TYPE,
convert_formdata,
+ deep_set,
deserialize_binary_form,
serialize_binary_form,
split_path
expect(res.data).toEqual({ a: 1 });
});
});
+
+describe('deep_set', () => {
+ test('always creates own property', () => {
+ const target = {};
+
+ deep_set(target, ['toString', 'property'], 'hello');
+
+ // @ts-ignore
+ expect(target.toString.property).toBe('hello');
+ // @ts-ignore
+ expect(Object.prototype.toString.property).toBeUndefined();
+ });
+});