From 4ae59d6d027baf6eb93ef59623389e48a2c11c5a Mon Sep 17 00:00:00 2001 From: Cyborus <87248184+Cyborus04@users.noreply.github.com> Date: Mon, 13 Nov 2023 18:49:08 -0500 Subject: [PATCH] remove leading slashes --- src/issue.rs | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/issue.rs b/src/issue.rs index ccc1854..673d0bb 100644 --- a/src/issue.rs +++ b/src/issue.rs @@ -6,23 +6,22 @@ impl Forgejo { } pub async fn create_issue(&self, owner: &str, repo: &str, opts: CreateIssueOption) -> Result { - self.post(&format!("/repos/{owner}/{repo}/issues"), &opts).await + self.post(&format!("repos/{owner}/{repo}/issues"), &opts).await } pub async fn get_issue(&self, owner: &str, repo: &str, id: u64) -> Result, ForgejoError> { - self.get_opt(&format!("/repos/{owner}/{repo}/issues/{id}")).await + self.get_opt(&format!("repos/{owner}/{repo}/issues/{id}")).await } pub async fn delete_issue(&self, owner: &str, repo: &str, id: u64) -> Result<(), ForgejoError> { - self.delete(&format!("/repos/{owner}/{repo}/issues/{id}")).await + self.delete(&format!("repos/{owner}/{repo}/issues/{id}")).await } pub async fn edit_issue(&self, owner: &str, repo: &str, id: u64, opts: EditIssueOption) -> Result { - self.patch(&format!("/repos/{owner}/{repo}/issues/{id}"), &opts).await + self.patch(&format!("repos/{owner}/{repo}/issues/{id}"), &opts).await } - pub async fn get_repo_comments(&self, owner: &str, repo: &str, query: RepoCommentQuery) -> Result, ForgejoError> { self.get(&query.to_string(owner, repo)).await } @@ -32,19 +31,19 @@ impl Forgejo { } pub async fn create_comment(&self, owner: &str, repo: &str, issue_id: u64, opts: CreateIssueCommentOption) -> Result { - self.post(&format!("/repos/{owner}/{repo}/issues/{issue_id}/comments"), &opts).await + self.post(&format!("repos/{owner}/{repo}/issues/{issue_id}/comments"), &opts).await } pub async fn get_comment(&self, owner: &str, repo: &str, id: u64) -> Result, ForgejoError> { - self.get_opt(&format!("/repos/{owner}/{repo}/issues/comments/{id}")).await + self.get_opt(&format!("repos/{owner}/{repo}/issues/comments/{id}")).await } pub async fn delete_comment(&self, owner: &str, repo: &str, id: u64) -> Result<(), ForgejoError> { - self.delete(&format!("/repos/{owner}/{repo}/issues/comments/{id}")).await + self.delete(&format!("repos/{owner}/{repo}/issues/comments/{id}")).await } pub async fn edit_comment(&self, owner: &str, repo: &str, id: u64, opts: EditIssueCommentOption) -> Result { - self.patch(&format!("/repos/{owner}/{repo}/issues/comments/{id}"), &opts).await + self.patch(&format!("repos/{owner}/{repo}/issues/comments/{id}"), &opts).await } } @@ -154,7 +153,7 @@ pub struct IssueQuery { impl IssueQuery { fn to_string(&self, owner: &str, repo: &str) -> String { - format!("/repos/{owner}/{repo}/issues?state={}&labels={}&q={}&type={}&milestones={}&since={}&before={}&created_by={}&assigned_by={}&mentioned_by={}&page={}&limit={}", + format!("repos/{owner}/{repo}/issues?state={}&labels={}&q={}&type={}&milestones={}&since={}&before={}&created_by={}&assigned_by={}&mentioned_by={}&page={}&limit={}", self.state.map(|s| s.as_str()).unwrap_or_default(), self.labels.join(","), self.query.as_deref().unwrap_or_default(), @@ -194,7 +193,7 @@ pub struct IssueCommentQuery { impl IssueCommentQuery { fn to_string(&self, owner: &str, repo: &str, issue_id: u64) -> String { - format!("/repos/{owner}/{repo}/issues/{issue_id}/comments?since={}&before={}", + format!("repos/{owner}/{repo}/issues/{issue_id}/comments?since={}&before={}", self.since.map(|t| t.format(&time::format_description::well_known::Rfc3339).unwrap()).unwrap_or_default(), self.before.map(|t| t.format(&time::format_description::well_known::Rfc3339).unwrap()).unwrap_or_default(), ) @@ -211,7 +210,7 @@ pub struct RepoCommentQuery { impl RepoCommentQuery { fn to_string(&self, owner: &str, repo: &str) -> String { - format!("/repos/{owner}/{repo}/issues/comments?since={}&before={}&page={}&limit={}", + format!("repos/{owner}/{repo}/issues/comments?since={}&before={}&page={}&limit={}", self.since.map(|t| t.format(&time::format_description::well_known::Rfc3339).unwrap()).unwrap_or_default(), self.before.map(|t| t.format(&time::format_description::well_known::Rfc3339).unwrap()).unwrap_or_default(), self.page.map(|page| page.to_string()).unwrap_or_default(),