feat(search): redirect u/ and user/ to profile (#268)

This commit is contained in:
DokterKaj 2024-09-27 20:29:33 +08:00 committed by GitHub
parent fe4fed0504
commit 8d0ed4682e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -69,10 +69,14 @@ pub async fn find(req: Request<Body>) -> Result<Response<Body>, String> {
return Ok(redirect("/")); return Ok(redirect("/"));
} }
if query.starts_with("r/") { if query.starts_with("r/") || query.starts_with("user/") {
return Ok(redirect(&format!("/{query}"))); return Ok(redirect(&format!("/{query}")));
} }
if query.starts_with("u/") {
return Ok(redirect(&format!("/user{}", &query[1..])));
}
let sub = req.param("sub").unwrap_or_default(); let sub = req.param("sub").unwrap_or_default();
let quarantined = can_access_quarantine(&req, &sub); let quarantined = can_access_quarantine(&req, &sub);
// Handle random subreddits // Handle random subreddits