Skip to content

Commit

Permalink
fix: use get_query to fix bad query strings
Browse files Browse the repository at this point in the history
  • Loading branch information
arlyon committed Apr 7, 2022
1 parent 87fa0c4 commit f032570
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions src/params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,14 +217,11 @@ impl<T: DeserializeOwned + Send + 'static> List<T> {
/// Prefer `List::next` when possible
pub fn get_next(client: &Client, url: &str, last_id: &str) -> Response<List<T>> {
if url.starts_with("/v1/") {
// TODO: Maybe parse the URL? Perhaps `List` should always parse its `url` field.
let mut url = url.trim_start_matches("/v1/").to_string();
if url.contains('?') {
url.push_str(&format!("&starting_after={}", last_id));
} else {
url.push_str(&format!("?starting_after={}", last_id));
}
client.get(&url)
let path = url.trim_start_matches("/v1/").to_string(); // the url we get back is prefixed
client.get_query(
&path,
[("starting_after", last_id)].iter().cloned().collect::<HashMap<_, _>>(),
)
} else {
err(StripeError::UnsupportedVersion)
}
Expand Down

0 comments on commit f032570

Please sign in to comment.