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

Comma separator may not be encoded #387

Open
Gnuk opened this issue Dec 15, 2020 · 3 comments
Open

Comma separator may not be encoded #387

Gnuk opened this issue Dec 15, 2020 · 3 comments

Comments

@Gnuk
Copy link

Gnuk commented Dec 15, 2020

I see some issues with arrayFormat: 'comma':

What happens today:

qs.stringify({list: ['foo,bar', 'hello', 'world']}, { arrayFormat: 'comma' });

returns:

list=foo%2Cbar%2Chello%2Cworld

instead of:

list=foo%2Cbar,hello,world

Suggested test case (i did it in jest/jasmine format):

it('Should put comma when arrayFormat is comma', () => {
  expect(qs.stringify({list: ['foo,bar', 'hello', 'world']}, { arrayFormat: 'comma' })).toBe('list=foo%2Cbar,hello,world');
});
@ljharb
Copy link
Owner

ljharb commented Dec 15, 2020

Seems related to #237.

@Ugzuzg
Copy link

Ugzuzg commented Apr 19, 2021

The solution would be to apply the encoder to each value of the array before joining them with a comma. I haven't found an easy way to do that without making major changes to the stringify function.

@ljharb
Copy link
Owner

ljharb commented Apr 19, 2021

Although I prefer to avoid it, major changes to the implementation are reasonable if all the current tests pass.

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

3 participants