Skip to content

Conversation

@OmarMohamedoi
Copy link

In this fix the solution handles null and empty strings properly in the stringify function when using arrayFormat:'comma'. The fix ensures that null values and empty strings are not skipped when the skipNull and skipEmptyString options are set to false. it addresses how the comma array format should properly place commas for those null and empty string values in the output.

.js
Comment on lines +1 to +19
const queryString = require('./index');

// Example data that includes null and empty strings
const params = {
list: ['item', '', null, 'last']
};

// Options to reproduce the bug
const options = {
arrayFormat: 'comma',
skipNull: false,
skipEmptyString: false
};

// Stringify the parameters with the options
const result = queryString.stringify(params, options);

// Log the result to console
console.log(result); // Expected to incorrectly skip null and empty strings based on the bug
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This example should be in the comment of the PR or expressed via a passing unit test. This file can't be merged into main

@scottenock scottenock mentioned this pull request Dec 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants