diff --git a/actix/src/main.rs b/actix/src/main.rs index f419800..439d5fe 100644 --- a/actix/src/main.rs +++ b/actix/src/main.rs @@ -70,12 +70,12 @@ async fn error404() -> impl Responder { async fn link_handler(shortlink: web::Path, data: web::Data) -> 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 diff --git a/actix/src/utils.rs b/actix/src/utils.rs index b7c9d0a..d470643 100644 --- a/actix/src/utils.rs +++ b/actix/src/utils.rs @@ -28,14 +28,14 @@ pub fn add_link(req: String, db: &Connection) -> (bool, String) { let mut shortlink; if chunks.len() > 1 { shortlink = chunks[1].to_string().to_lowercase(); - if shortlink == *"" { + if shortlink.is_empty() { shortlink = random_name(); } } else { shortlink = random_name(); } - if validate_link(shortlink.as_str()) && get_longurl(shortlink.clone(), db) == *"" { + if validate_link(shortlink.as_str()) && get_longurl(shortlink.clone(), db).is_empty() { ( database::add_link(shortlink.clone(), longlink, db), shortlink,