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

In 'a&b=' treat a as boolean flag (true) #79

Closed
scharf opened this issue Mar 26, 2015 · 4 comments
Closed

In 'a&b=' treat a as boolean flag (true) #79

scharf opened this issue Mar 26, 2015 · 4 comments
Assignees
Milestone

Comments

@scharf
Copy link
Contributor

scharf commented Mar 26, 2015

If no = is given for a flag, it should be handled as boolean (true).

For example:

Qs.parse('a&b=', {allowBoolean: true});
//  {a: true, b: ''}

without the allowBoolean option, it should not do this conversion (as it does today):

Qs.parse('a&b=');
//  {a: '', b: ''}
@pierot
Copy link
Contributor

pierot commented May 19, 2015

I would argue that the other way around, giving a null as value for a key, should generate a querystring value without the =.

Qs.stringify({a: null, b: "test"});
// ?a&b=test

Empty string could still behave as it is doing right now:

Qs.stringify({a: null, b: "test", c: ""});
// ?a&b=test&c=

@scharf
Copy link
Contributor Author

scharf commented May 19, 2015

@pierot That makes a lot of sense!

Else the following assertion fails:

assert.deepEqual(
    Qs.parse(Qs.stringify({a: null, b: "test", c: ""})),  // a=&b=test&c=
    {a: null, b: "test", c: ""}                           // {a: "", b: "test", c: ""} 
);

@pierot pierot mentioned this issue May 19, 2015
@pierot
Copy link
Contributor

pierot commented May 19, 2015

I made a pull request for this: #85

@nlf nlf added this to the 3.0.0 milestone May 21, 2015
@nlf nlf self-assigned this May 21, 2015
@nlf
Copy link
Collaborator

nlf commented May 21, 2015

Closed via #85

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

4 participants