Skip to content

Commit e3f9792

Browse files
authored
Merge pull request #285 from swwind/master
Make QR code as short as possible
2 parents 624dc7e + 4ae803e commit e3f9792

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

src/endpoints/qr.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,16 @@ pub async fn getqr(data: web::Data<AppState>, id: web::Path<String>) -> HttpResp
4343

4444
if found {
4545
// generate the QR code as an SVG - if its a file or text pastas, this will point to the /upload endpoint, otherwise to the /url endpoint, essentially directly taking the user to the url stored in the pasta
46-
let svg: String = match pastas[index].pasta_type.as_str() {
47-
"url" => misc::string_to_qr_svg(
48-
format!("{}/url/{}", &ARGS.public_path_as_str(), &id).as_str(),
49-
),
50-
_ => misc::string_to_qr_svg(
51-
format!("{}/upload/{}", &ARGS.public_path_as_str(), &id).as_str(),
52-
),
53-
};
46+
let svg = misc::string_to_qr_svg(&match pastas[index].pasta_type.as_str() {
47+
"url" => match ARGS.short_path.as_ref() {
48+
Some(short) => format!("{short}/u/{id}"),
49+
_ => format!("{}/url/{}", &ARGS.public_path_as_str(), &id),
50+
},
51+
_ => match ARGS.short_path.as_ref() {
52+
Some(short) => format!("{short}/p/{id}"),
53+
_ => format!("{}/upload/{}", &ARGS.public_path_as_str(), &id),
54+
},
55+
});
5456

5557
// serve qr code in template
5658
return HttpResponse::Ok().content_type("text/html").body(

0 commit comments

Comments
 (0)