build: do not append params if they don't exist.

This commit is contained in:
Jordan Petridis 2018-06-26 14:46:35 +03:00
parent c4f69d6f6c
commit 16a062c105

View file

@ -950,10 +950,13 @@ pub fn build_url(base: &Url, path: &str, params: Vec<(&str, String)>) -> Result<
let mut url = base.join(path)?; let mut url = base.join(path)?;
{ {
let mut query = url.query_pairs_mut(); // If len was 0 `?` would be appended without being needed.
query.clear(); if params.len() >= 1 {
for (k, v) in params { let mut query = url.query_pairs_mut();
query.append_pair(k, &v); query.clear();
for (k, v) in params {
query.append_pair(k, &v);
}
} }
} }