fix url decoding in /uploaded endpoint

This commit is contained in:
neri 2022-11-22 21:11:59 +01:00
parent dc2f7ecab0
commit b9849153f0
1 changed files with 8 additions and 6 deletions

View File

@ -140,15 +140,17 @@ fn get_file_url(req: &HttpRequest, id: &str, name: Option<&str>) -> String {
} }
} }
pub async fn uploaded(req: HttpRequest) -> Result<HttpResponse, Error> { pub async fn uploaded(
let id = req.match_info().query("id"); req: HttpRequest,
let name = req.match_info().get("name"); path: web::Path<(String, Option<String>)>,
) -> Result<HttpResponse, Error> {
let (id, name) = path.into_inner();
let upload_html = if name.is_some() { let upload_html = if name.is_some() {
UPLOAD_SHORT_HTML UPLOAD_SHORT_HTML
.replace("{link}", &get_file_url(&req, id, name)) .replace("{link}", &get_file_url(&req, &id, name.as_deref()))
.replace("{shortlink}", &get_file_url(&req, id, None)) .replace("{shortlink}", &get_file_url(&req, &id, None))
} else { } else {
UPLOAD_HTML.replace("{link}", &get_file_url(&req, id, name)) UPLOAD_HTML.replace("{link}", &get_file_url(&req, &id, name.as_deref()))
}; };
Ok(HttpResponse::Ok() Ok(HttpResponse::Ok()
.content_type("text/html") .content_type("text/html")