Skip to content

toPath doesn't support quoted strings inside brackets (redux-form did...) #380

@jedwards1211

Description

@jedwards1211

Are you submitting a bug report or a feature request?

bug report

What is the current behavior?

toPath splits 'foo["bar.baz"]' to ['foo', '"bar', 'baz"']

It's impossible to use a nested object key with . in the name and messy to use a nested object key that's not a valid JS identifier. 'foo["bar.baz"]' is an idiomatic JS pathstring supported by libs like lodash.get:

_.get({foo: {"bar.baz": 3}}, 'foo["bar.baz"]') // 3

I have to use an arbitrary, user-entered string value as part of the nested object key, so I need final-form to support quoting and escaping properly here.

My field name that was working fine in redux-form and is now broken with final-form is "Channels["{\"type\":\"MetadataItem\",\"connectionId\":14,\"direction\":\"FROM_GATEWAY\",\"tag\":\"mqttChannel1\"}"].internalTag".
mqttChannel1 is the user-entered value, and I'm using JSON.stringify to safely escape the object that forms this key.

What is the expected behavior?

toPath splits 'foo["bar.baz"]' to ['foo', 'bar.baz']

What's your environment?

not relevant

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