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

fix: allow empty json body #20

Merged
merged 2 commits into from
May 4, 2023
Merged

Conversation

fernando7jr
Copy link
Contributor

The json middleware crashes when it receives an empty string from req.chunk.
This causes JSON.parse() to throw an exception since it does not accept empty strings.

The json middleware crashes when it receives an empty string from req.chunk
This causes JSON.parse() to throw an exception since it does not accept empty strings
})

await makeFetch(server)('/', {
body: '',
Copy link

Choose a reason for hiding this comment

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

Maybe you could also test the case where no body is set at all. In think your code handles it as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hey, took me long to recheck this PR but I included the other test case too

Added a check for unset body on the test "should ignore JSON empty body"
@talentlessguy talentlessguy merged commit 7ef500f into tinyhttp:master May 4, 2023
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