From 471be87ecf248d0afedd4e1cf64959a04add184d Mon Sep 17 00:00:00 2001 From: softprops Date: Sun, 25 Aug 2019 23:40:13 -0400 Subject: [PATCH] use RequestBuilder.query to manage url encoding --- src/github.rs | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) diff --git a/src/github.rs b/src/github.rs index abe924b..a79773c 100644 --- a/src/github.rs +++ b/src/github.rs @@ -79,17 +79,6 @@ impl Releaser for Client { } } -fn asset_url( - github_repo: &str, - release_id: usize, - name: &str, -) -> String { - format!( - "http://uploads.github.com/repos/{}/releases/{}/assets?name={}", - github_repo, release_id, name - ) -} - impl> AssetUploader for Client { // https://developer.github.com/v3/repos/releases/#upload-a-release-asset fn upload( @@ -102,9 +91,13 @@ impl> AssetUploader for Client { asset: A, ) -> Result> { Ok(self - .post(&asset_url(github_repo, release_id, name)) + .post(&format!( + "http://uploads.github.com/repos/{}/releases/{}/assets", + github_repo, release_id + )) .header("Authorization", format!("bearer {}", github_token)) .header("Content-Type", mime.to_string()) + .query(&[("name", name)]) .body(asset) .send()? .status()) @@ -113,12 +106,6 @@ impl> AssetUploader for Client { #[cfg(test)] mod tests { - use super::*; #[test] - fn asset_url_formats_urls() { - assert_eq!( - "http://uploads.github.com/repos/foo/bar/releases/1/assets?name=release.txt", - asset_url("foo/bar", 1, "release.txt") - ) - } + fn it_works() {} }