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

Lack of symmetry between parse and stringify #295

Open
roberttaylor426 opened this issue Nov 10, 2020 · 3 comments
Open

Lack of symmetry between parse and stringify #295

roberttaylor426 opened this issue Nov 10, 2020 · 3 comments

Comments

@roberttaylor426
Copy link

roberttaylor426 commented Nov 10, 2020

stringify(parse('?%20&')) yields only &.

Bit of an edge-case I admit, but do we want to be losing this information?

parse('?%20&') yields {"":null," ":null}.

@sindresorhus
Copy link
Owner

I think parse('?%20&') should result in {}. Keeping empty keys or whitespace only keys are not useful.

@sindresorhus sindresorhus changed the title Lack of symmetry between parse and stringify. Lack of symmetry between parse and stringify Nov 20, 2020
@roberttaylor426
Copy link
Author

roberttaylor426 commented Nov 27, 2020

I'd be happy to take a look at this.

In my opinion assuming empty or whitespace-only keys are not useful to the client feels a little presumptuous. If someone tries to parse '?%20&', isn't {"":null," ":null} the honest response? (Either that or {"":""," ":""}).

@sindresorhus
Copy link
Owner

I don't think anyone would actually do this in real code though. If you really think it matters, we could document the behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants