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> {
let id = req.match_info().query("id");
let name = req.match_info().get("name");
pub async fn uploaded(
req: HttpRequest,
path: web::Path<(String, Option<String>)>,
) -> Result<HttpResponse, Error> {
let (id, name) = path.into_inner();
let upload_html = if name.is_some() {
UPLOAD_SHORT_HTML
.replace("{link}", &get_file_url(&req, id, name))
.replace("{shortlink}", &get_file_url(&req, id, None))
.replace("{link}", &get_file_url(&req, &id, name.as_deref()))
.replace("{shortlink}", &get_file_url(&req, &id, None))
} 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()
.content_type("text/html")