sodiray / radash

Functional utility library - modern, simple, typed, powerful
https://radash-docs.vercel.app
MIT License
4.1k stars 160 forks source link

construct sometimes converts integers with letters into an array instead of an object #389

Open schinwald opened 5 months ago

schinwald commented 5 months ago

When using construct I am getting unexpected behaviour, which is causing data to get lost. It happens specifically when there is a number followed by a letter somewhere in the middle of a path to be constructed (in the case below 2fa). It works fine in the root though.

import { construct } from "radash";

const good = construct({ '2fa.enabled': true })
console.log(good)
/**
 * {
 *   '2fa': {
 *     enabled: true
 *   }
 * }
 */

const bad = construct({ 'email.2fa.enabled': true })
console.log(bad)
/**
 * {
 *   email: []
 * }
 */