From 9c325c2cbff9705700015e47d1e3f733c2527363 Mon Sep 17 00:00:00 2001 From: Andrew Kaufman <57281817+andrew-kaufman@users.noreply.github.com> Date: Wed, 5 Jan 2022 14:06:41 -0800 Subject: [PATCH] Search fixes (#384) * Default to searching within subreddit * Redirect to subreddit from search --- src/search.rs | 4 ++++ templates/utils.html | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/search.rs b/src/search.rs index d430244..3547679 100644 --- a/src/search.rs +++ b/src/search.rs @@ -54,6 +54,10 @@ pub async fn find(req: Request) -> Result, String> { return Ok(redirect("/".to_string())); } + if query.starts_with("r/") { + return Ok(redirect(format!("/{}", query))); + } + let sub = req.param("sub").unwrap_or_default(); let quarantined = can_access_quarantine(&req, &sub); // Handle random subreddits diff --git a/templates/utils.html b/templates/utils.html index fdfe350..81a4bd4 100644 --- a/templates/utils.html +++ b/templates/utils.html @@ -19,7 +19,7 @@ {% if root != "/r/" && !root.is_empty() %}
- +
{% endif %}