dominictarr/rc

primitive key may get error

Opened this issue · 2 comments

in folder lib utils.js

    if (cursor[_subkey] === undefined) {
        console.log('undefined ' + cursor);
        cursor[_subkey] = {}
    }

where cursor[_subkey] is a primitive value ,like boolean , cursor[_subkey] = {} may get undefined value.

so code below

    // Increment cursor used to track the object at the current depth
    cursor = cursor[_subkey]

will still got an undefind value.

I just don't much about rc, I found this problem when I install another project.

tks

I try to fix this like code blow

    // Build sub-object if nothing already exists at the keypath
    if (cursor[_subkey] === undefined) {
        cursor = {}
    } else {
        // Increment cursor used to track the object at the current depth
        cursor = cursor[_subkey]
    }

And It sems works.

Above that there is this line:

if (!_subkey || typeof cursor !== 'object')
          return

That should make it so that now primitive keys actually get to that point.