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: unify body and query serialisation behaviour #1808

Merged

Conversation

MaoShizhong
Copy link
Contributor

@MaoShizhong MaoShizhong commented Jun 29, 2024

Because

#1591 changed things to use qs to serialise form data. However, that change set qs.stringify as the body serialisation function i.e. default options. The existing query serialisation uses qs.stringify with indices: false and strictNullHandling: true options (src/node/index.js line 679).

Existing documentation indicates that body serialisation with duplicated object keys should result in the same behaviour as the existing query serialisation. However, qs.stringify with default options results in a different outcome, as described in the issue this PR closes.

This PR

  • Changes body serialisation function to match existing query serialisation function and options, bringing its behaviour in line with existing documentation
  • Adds test for serialising duplicated keys

Linked issue

Closes #1798

Checklist

  • I have ensured my pull request is not behind the main or master branch of the original repository.
  • I have rebased all commits where necessary so that reviewing this pull request can be done without having to merge it first.
  • I have written a commit message that passes commitlint linting.
  • I have ensured that my code changes pass linting tests.
  • I have ensured that my code changes pass unit tests.
  • I have described my pull request and the reasons for code changes along with context if necessary.

@MaoShizhong
Copy link
Contributor Author

@titanism anything extra I might need to fix the above?

@titanism titanism merged commit bfb2d00 into ladjs:master Aug 24, 2024
2 checks passed
@MaoShizhong MaoShizhong deleted the fix/unify-body-query-serialisation-behaviour branch August 24, 2024 19:37
@titanism
Copy link
Collaborator

v10.1.0 released to npm, thank you @MaoShizhong

ref: https://github.com/ladjs/superagent/releases/tag/v10.1.0

p.s. our efforts to maintain this repo are supported by @forwardemail

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.

[fix] qs.stringify does not serialise arrays in objects according to documentation
2 participants