Strip undefined values from URL params; disallow some forms for params
#88
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Being able to specify
params
as a single record object is very convenient, but it becomes inconvenient when some parameters are optional. Previously you could not use the record object syntax if a parameter is optional. Now you can use that syntax and we will strip undefined values, likeJSON.stringify
.Previously we allowed all of the various forms of data that can be passed to
new URLSearchParams()
(and in fact just passed what we got directly to there). Implementing this undefined-stripping for all of the forms (like "arbitrary iterable object of two-element arrays") would be a lot of code copied from the DOM implementation, but not stripping undefined from the other forms would be inconsistent. So we change to only allow the record form (which is the only form that our docs show) plus providingURLSearchParams
yourself; if you used one of the other forms you can just add anew URLSearchParams()
to your code.See the changeset entry for more details.
Fixes #24.