Remove share parameters at canonical_path

This commit is contained in:
Matthew Esposito 2023-12-29 19:34:57 -05:00
parent 45d8f1bbc8
commit 90a800ff44
No known key found for this signature in database
2 changed files with 10 additions and 6 deletions

View file

@ -335,10 +335,7 @@ 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)) => {
// Remove share parameters here.
Ok(redirect(path.split('?').next().unwrap_or_default().to_string()))
}
Ok(Some(path)) => Ok(redirect(path)),
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,
},