Remove '?' prefix in FeedOption::build_url #88
Merged
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.
Repeated inclusion of "?" to identify the query string will cause any parameters to which "?" is appended to be treated as "param?". This leads to the parameter being ignored by the Reddit API as it cannot be parsed correctly.
For example, when calling
Subreddit::new("ipad").latest(1, Some(FeedOption::new())
, the URL will be formatted as "https://www.reddit.com/r/Watchexchange/new.json?limit=1?", andlimit=1
is ignored.For now, let's remove the "?" appending in
FeedOption::build_url
and instead include it in every URL passed tobuild_url
.Ultimately, we should probably rethink how we're specifying options. Current design, for example, allows limit to be specified twice in many places. The second limit specified in the URL will always be the one used (overriding the first).
Likewise, the splitting of options between
FeedOptions
and as function parameters makes for a confusing API. IfFeedOptions
are truly applicable everywhere, then we should remove redundant provisions oflimit
. If certain options (e.g.,before
andafter
) are only applicable in certain places, then perhaps we can forgoFeedOptions
and provide the appropriate parameters for each function corresponding to a REST API call.