Skip to content

Commit

Permalink
better error msg for link post missing
Browse files Browse the repository at this point in the history
  • Loading branch information
glendc committed Oct 24, 2023
1 parent 8bfa10b commit 565a37b
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/router/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ pub async fn post(
if let Some(email) = state.auth.verify_cookie(cookie.value()) {
if params.long.is_empty() {
return LinkPostResponse::BadRequest {
reason: "URL is not specified",
reason: "URL is not specified.",
long: params.long,
};
}
Expand Down Expand Up @@ -161,7 +161,11 @@ impl IntoResponse for LinkPostResponse {
StatusCode::BAD_REQUEST,
super::shared::ErrorTemplate {
title: "Invalid Long URL".to_string(),
message: format!("The long URL '{}' is invalid. {}", long, reason,),
message: if long.is_empty() {
format!("The long URL is invalid. {}", reason)
} else {
format!("The long URL '{}' is invalid. {}", long, reason)
},
back_path: format!("/link?long={}", long),
},
)
Expand Down

0 comments on commit 565a37b

Please sign in to comment.