Better handle redirects with new OAuth endpoints

This commit is contained in:
Matthew Esposito 2023-12-29 19:28:41 -05:00
parent 3a4a39f577
commit 45d8f1bbc8
No known key found for this signature in database
4 changed files with 25 additions and 4 deletions

View file

@ -335,7 +335,10 @@ async fn main() {
match req.param("id").as_deref() {
// Share link
Some(id) if (8..12).contains(&id.len()) => match canonical_path(format!("/r/{}/s/{}", sub, id)).await {
Ok(Some(path)) => Ok(redirect(path.split('?').next().unwrap_or_default().to_string())),
Ok(Some(path)) => {
// Remove share parameters here.
Ok(redirect(path.split('?').next().unwrap_or_default().to_string()))
}
Ok(None) => error(req, "Post ID is invalid. It may point to a post on a community that has been banned.").await,
Err(e) => error(req, e).await,
},