Skip to content

Fix overwriting of queryItems with nil#51

Merged
djones6 merged 3 commits intomasterfrom
queryItems
Jan 28, 2019
Merged

Fix overwriting of queryItems with nil#51
djones6 merged 3 commits intomasterfrom
queryItems

Conversation

@djones6
Copy link
Contributor

@djones6 djones6 commented Jan 28, 2019

Resolves #42

RestRequest provides two ways to configure the query parameters for the request: one is by setting the queryItems field, the other is by passing them to one of the func responseXXX(..., queryItems:) functions.

If the queryItems param is not provided, it defaults to nil. However, that then unconditionally overwrites the values on the RestRequest. This seems counter-intuitive, and means the only way to use the currently configured queryItems would be to pass it as a parameter, ie. request.responseObject(..., queryItems: request.queryItems).

This PR makes the overwriting conditional on the queryItems param being non-nil.

Following this change, it is no longer possible to (explicitly or implicitly) pass queryItems: nil to clear the current query parameters. Instead, the user should set request.queryItems = nil before calling a response function.

@djones6 djones6 requested a review from ianpartridge January 28, 2019 13:51
@djones6 djones6 merged commit 523f389 into master Jan 28, 2019
@djones6 djones6 deleted the queryItems branch January 28, 2019 16:28
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.

2 participants