diff --git a/.gitignore b/.gitignore index ba3c334..6c9a53b 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,5 @@ tags /target **/*.rs.bk -.vscode \ No newline at end of file +.vscode +.idea diff --git a/src/models/me/mod.rs b/src/models/me/mod.rs index c54df2f..8bb01a7 100644 --- a/src/models/me/mod.rs +++ b/src/models/me/mod.rs @@ -177,7 +177,7 @@ impl Me { #[maybe_async::maybe_async] pub async fn saved(&self, options: Option) -> Result { let url = &mut format!( - "user/{}/saved/.json", + "user/{}/saved/.json?", self.config.username.to_owned().unwrap() ); @@ -192,7 +192,7 @@ impl Me { #[maybe_async::maybe_async] pub async fn upvoted(&self, options: Option) -> Result { let url = &mut format!( - "user/{}/upvoted/.json", + "user/{}/upvoted/.json?", self.config.username.to_owned().unwrap() ); @@ -207,7 +207,7 @@ impl Me { #[maybe_async::maybe_async] pub async fn downvoted(&self, options: Option) -> Result { let url = &mut format!( - "user/{}/downvoted/.json", + "user/{}/downvoted/.json?", self.config.username.to_owned().unwrap() ); diff --git a/src/models/user/mod.rs b/src/models/user/mod.rs index 3544424..68acc3d 100644 --- a/src/models/user/mod.rs +++ b/src/models/user/mod.rs @@ -52,7 +52,7 @@ impl User { /// Get user's overview. #[maybe_async::maybe_async] pub async fn overview(&self, options: Option) -> Result { - let url = &mut format!("https://www.reddit.com/user/{}/overview/.json", self.user); + let url = &mut format!("https://www.reddit.com/user/{}/overview/.json?", self.user); if let Some(options) = options { options.build_url(url); @@ -70,7 +70,7 @@ impl User { /// Get user's submitted posts. #[maybe_async::maybe_async] pub async fn submitted(&self, options: Option) -> Result { - let url = &mut format!("https://www.reddit.com/user/{}/submitted/.json", self.user); + let url = &mut format!("https://www.reddit.com/user/{}/submitted/.json?", self.user); if let Some(options) = options { options.build_url(url); @@ -88,7 +88,7 @@ impl User { /// Get user's submitted comments. #[maybe_async::maybe_async] pub async fn comments(&self, options: Option) -> Result { - let url = &mut format!("https://www.reddit.com/user/{}/comments/.json", self.user); + let url = &mut format!("https://www.reddit.com/user/{}/comments/.json?", self.user); if let Some(options) = options { options.build_url(url); @@ -106,7 +106,7 @@ impl User { /// Get user's about page #[maybe_async::maybe_async] pub async fn about(&self, options: Option) -> Result { - let url = &mut format!("https://www.reddit.com/user/{}/about/.json", self.user); + let url = &mut format!("https://www.reddit.com/user/{}/about/.json?", self.user); if let Some(options) = options { options.build_url(url); diff --git a/src/util/option.rs b/src/util/option.rs index ec6db1d..1c14738 100644 --- a/src/util/option.rs +++ b/src/util/option.rs @@ -72,9 +72,6 @@ impl FeedOption { /// Build a url from `FeedOption` pub fn build_url(self, url: &mut String) { - // Add a fake url attr so I don't have to parse things - url.push_str(&String::from("?")); - if let Some(after) = self.after { url.push_str(&format!("&after={}", after)); } else if let Some(before) = self.before { @@ -150,7 +147,7 @@ mod tests { let url = &mut String::from(""); options.build_url(url); - assert!(*url == format!("?&after={}&", after)) + assert!(*url == format!("&after={}&", after)) } #[test] @@ -161,7 +158,7 @@ mod tests { let url = &mut String::from(""); options.build_url(url); - assert!(*url == format!("?&before={}&", before)) + assert!(*url == format!("&before={}&", before)) } #[test] @@ -172,6 +169,6 @@ mod tests { let url = &mut String::from(""); options.build_url(url); - assert!(*url == format!("?&count={}&", count)) + assert!(*url == format!("&count={}&", count)) } }