Skip to content

get of nonexistent path returns value of parent if it's a falsy value #22

@andrewwalters

Description

@andrewwalters

Do you want to request a feature or report a bug?

Bug

What is the current behavior?

If a get is performed with a non-existent path, and a parent of the path does exist and is a falsy value, then that value is returned instead of undefined.

If the current behavior is a bug, please provide the steps to reproduce.
What is the expected behavior?

From the node REPL:

> mpath.get('x.y', { x: 0 })
0 // Expect: undefined
> mpath.get('x.y', { x: false })
false // Expect: undefined
> mpath.get('x.y', { x: null })
null // Expect: undefined
> mpath.get('x.y', { x: 1 })
undefined // Ok
> mpath.get('x.y', { x: { y: 'z' } })
'z' // Ok

What are the versions of Node.js and mpath are you are using? Note that "latest" is not a version.

node 16.19.0
mpath 0.9.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions