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

Allow strictNullHandling to work when using a custom filter #279

Merged
merged 1 commit into from
Nov 23, 2018
Merged

Allow strictNullHandling to work when using a custom filter #279

merged 1 commit into from
Nov 23, 2018

Conversation

Neaox
Copy link
Contributor

@Neaox Neaox commented Sep 16, 2018

Fixes #278

Copy link
Owner

@ljharb ljharb left a comment

Choose a reason for hiding this comment

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

Can you please provide a test case, so it's clear what you expected to work, and how it failed?

@Neaox
Copy link
Contributor Author

Neaox commented Sep 17, 2018

Added a test as requested.

An explanation of the issue:

If you specify a custom filter in your stringify options the if case here (https://github.com/ljharb/qs/pull/279/files/ab07ce71f33704ecfac7298b055be8f481edf277#diff-dd5072864997b356b1727023f837c921L48) is run. Due the statement on line 52 (https://github.com/ljharb/qs/pull/279/files/ab07ce71f33704ecfac7298b055be8f481edf277#diff-dd5072864997b356b1727023f837c921L52) being an else if, instead of an if the null handling is not run, which then causes an error when attemping to get the keys of a null object.

By changing this else if to an if the issue is fixed.

Copy link
Owner

@ljharb ljharb left a comment

Choose a reason for hiding this comment

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

Thanks; I also added a test case for a serializeDate that returns null, which your fix also addresses.

@ljharb ljharb merged commit 98126ef into ljharb:master Nov 23, 2018
ljharb pushed a commit that referenced this pull request Jan 11, 2022
ljharb pushed a commit that referenced this pull request Jan 11, 2022
ljharb pushed a commit that referenced this pull request Jan 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants