Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dots in field names break the structure for multipart/form-data #63

Open
irshadahmad21 opened this issue Feb 17, 2024 · 4 comments
Open
Assignees
Labels
Semver: Patch A bug fix Type: Enhancement Improving an existing feature

Comments

@irshadahmad21
Copy link

Package version

v10.0.1

Describe the bug

For 'application/x-www-form-urlencoded', we have an option to pass queryString: { allowDots: false } but there is no such option for 'multipart/form-data' and the fields are parsed using dot for nesting.

We have a form that allows users to submit a URL along with other inputs and files. We need to store some meta related to the submitted URL in an input field like this

<input type='hidden' name={`meta[${url}][some_key]`} value={'some value'} />

The URL will obviously contain dots.

Reproduction repo

No response

@thetutlage
Copy link
Member

Can you share some sample field names for the same?

@thetutlage thetutlage self-assigned this Feb 17, 2024
@thetutlage thetutlage added the Type: Enhancement Improving an existing feature label Feb 17, 2024
@irshadahmad21
Copy link
Author

irshadahmad21 commented Feb 17, 2024

e.g.

<input type="hidden" name="meta[https://dns.mysite.com][ttl]" value="some value" />

The expected result is:

{
    "meta": {
        "https://dns.mysite.com": {
            "ttl": "some value"
        }
    }
}

The actual result is

{
    "meta": {
        "https://dns": {
            "mysite": {
                "com": {
                    "ttl": "some value"
                }
            }
        }
    }
}

@thetutlage
Copy link
Member

Yeah, seems like it needs a fix. For now (as a workaround), you can wrap the domain inside single quotes and it will work.

<input type="hidden" name="meta['https://dns.mysite.com'][ttl]" value="some value" />

@thetutlage thetutlage added the Semver: Patch A bug fix label Feb 20, 2024
@irshadahmad21
Copy link
Author

Yeah, seems like it needs a fix. For now (as a workaround), you can wrap the domain inside single quotes and it will work.

<input type="hidden" name="meta['https://dns.mysite.com'][ttl]" value="some value" />

Yeah, that works. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Semver: Patch A bug fix Type: Enhancement Improving an existing feature
Projects
None yet
Development

No branches or pull requests

2 participants