change: Do not dereference str whenever possible

This commit is contained in:
SinTan1729
2023-05-23 18:03:27 -05:00
parent 7b59a9aa5c
commit a4e7c6b444
2 changed files with 4 additions and 4 deletions

View File

@@ -70,12 +70,12 @@ async fn error404() -> impl Responder {
async fn link_handler(shortlink: web::Path<String>, data: web::Data<AppState>) -> impl Responder {
let shortlink_str = shortlink.to_string();
let longlink = utils::get_longurl(shortlink_str, &data.db);
if longlink == *"" {
if longlink.is_empty() {
Redirect::to("/err/404")
} else {
let redirect_method = env::var("redirect_method").unwrap_or(String::from("PERMANENT"));
database::add_hit(shortlink.as_str(), &data.db);
if redirect_method == *"TEMPORARY" {
if redirect_method == "TEMPORARY" {
Redirect::to(longlink)
} else {
// Defaults to permanent redirection