diff --git a/Cargo.toml b/Cargo.toml index 5c52375..69c23a6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,7 @@ name = "libreddit" description = " Alternative private front-end to Reddit" license = "AGPL-3.0" repository = "https://github.com/spikecodes/libreddit" -version = "0.10.0" +version = "0.10.1" authors = ["spikecodes <19519553+spikecodes@users.noreply.github.com>"] edition = "2018" @@ -22,4 +22,4 @@ route-recognizer = "0.3.0" serde_json = "1.0.64" tokio = { version = "1.4.0", features = ["full"] } time = "0.2.26" -url = "2.2.1" +url = "2.2.1" \ No newline at end of file diff --git a/src/client.rs b/src/client.rs index a3dcc98..784d1d8 100644 --- a/src/client.rs +++ b/src/client.rs @@ -7,7 +7,7 @@ use std::{result::Result, str::FromStr}; use crate::server::RequestExt; pub async fn proxy(req: Request, format: &str) -> Result, String> { - let mut url = format.to_string(); + let mut url = format!("{}?{}", format, req.uri().query().unwrap_or_default()); for (name, value) in req.params().iter() { url = url.replace(&format!("{{{}}}", name), value); diff --git a/src/main.rs b/src/main.rs index 0850008..543aa60 100644 --- a/src/main.rs +++ b/src/main.rs @@ -164,7 +164,7 @@ async fn main() { app.at("/img/:id").get(|r| proxy(r, "https://i.redd.it/{id}").boxed()); app.at("/thumb/:point/:id").get(|r| proxy(r, "https://{point}.thumbs.redditmedia.com/{id}").boxed()); app.at("/emoji/:id/:name").get(|r| proxy(r, "https://emoji.redditmedia.com/{id}/{name}").boxed()); - app.at("/preview/:loc/:id/:query").get(|r| proxy(r, "https://{loc}view.redd.it/{id}?{query}").boxed()); + app.at("/preview/:loc/:id").get(|r| proxy(r, "https://{loc}view.redd.it/{id}").boxed()); app.at("/style/*path").get(|r| proxy(r, "https://styles.redditmedia.com/{path}").boxed()); app.at("/static/*path").get(|r| proxy(r, "https://www.redditstatic.com/{path}").boxed()); diff --git a/src/utils.rs b/src/utils.rs index 412b3bf..1134000 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -431,8 +431,8 @@ pub fn format_url(url: &str) -> String { "a.thumbs.redditmedia.com" => capture(r"https://a\.thumbs\.redditmedia\.com/(.*)", "/thumb/a/", 1), "b.thumbs.redditmedia.com" => capture(r"https://b\.thumbs\.redditmedia\.com/(.*)", "/thumb/b/", 1), "emoji.redditmedia.com" => capture(r"https://emoji\.redditmedia\.com/(.*)/(.*)", "/emoji/", 2), - "preview.redd.it" => capture(r"https://preview\.redd\.it/(.*)\?(.*)", "/preview/pre/", 2), - "external-preview.redd.it" => capture(r"https://external\-preview\.redd\.it/(.*)\?(.*)", "/preview/external-pre/", 2), + "preview.redd.it" => capture(r"https://preview\.redd\.it/(.*)", "/preview/pre/", 1), + "external-preview.redd.it" => capture(r"https://external\-preview\.redd\.it/(.*)", "/preview/external-pre/", 1), "styles.redditmedia.com" => capture(r"https://styles\.redditmedia\.com/(.*)", "/style/", 1), "www.redditstatic.com" => capture(r"https://www\.redditstatic\.com/(.*)", "/static/", 1), _ => String::new(),