From: Simon Tatham Date: Sun, 31 Dec 2023 15:00:07 +0000 (+0000) Subject: Don't put '?' on the end of parameterless URLs. X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ian/git?a=commitdiff_plain;h=6a83f7e1cc1209455f38bd0d1e4395dbab1f8cad;p=mastodonochrome.git Don't put '?' on the end of parameterless URLs. If you call reqwest::Url::parse_with_params and give it an empty parameter iterator, it still appends '?' to the URL, and then doesn't put anything after it. I don't _think_ that actually makes any difference, but it looks ugly. More to the point, I noticed it while pasting HTTP transcripts to report a bug in the Mastodon dev setup, and thought I'd better try again without the spurious '?', in case it did make a difference. --- diff --git a/src/client.rs b/src/client.rs index 0a7cdfa..a9b4e03 100644 --- a/src/client.rs +++ b/src/client.rs @@ -184,7 +184,12 @@ impl Client { let urlstr = self.auth.instance_url.clone() + "/api/v1/" + &req.url_suffix; - let url = match Url::parse_with_params(&urlstr, req.parameters.iter()) { + let parsed = if req.parameters.is_empty() { + Url::parse(&urlstr) + } else { + Url::parse_with_params(&urlstr, req.parameters.iter()) + }; + let url = match parsed { Ok(url) => Ok(url), Err(e) => Err(ClientError::UrlParseError( urlstr.clone(), e.to_string())),