From 22f96705608bb90b3f4314024697fbbc89797ed0 Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Thu, 17 Mar 2022 18:24:10 +0100 Subject: [PATCH] Improve code readability --- src/utils/network_utils.rs | 2 +- src/utils/webpage_utils.rs | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/utils/network_utils.rs b/src/utils/network_utils.rs index ae9f44f..1e6a947 100644 --- a/src/utils/network_utils.rs +++ b/src/utils/network_utils.rs @@ -20,7 +20,7 @@ pub fn match_ip(pattern: &str, ip: &str) -> bool { return true; } - if pattern.ends_with("*") && ip.starts_with(&pattern.replace("*", "")){ + if pattern.ends_with('*') && ip.starts_with(&pattern.replace('*', "")) { return true; } diff --git a/src/utils/webpage_utils.rs b/src/utils/webpage_utils.rs index 9dd742d..ee642c7 100644 --- a/src/utils/webpage_utils.rs +++ b/src/utils/webpage_utils.rs @@ -11,11 +11,13 @@ use crate::data::post::PostWebLink; /// Attempt to get information about a URL given by a user pub fn get_post_web_link(url: &str) -> Res { - let mut options = WebpageOptions::default(); - options.max_redirections = 2; - options.follow_location = true; - options.useragent = "OpenGraph Fetcher v1.0".to_string(); - options.timeout = Duration::from_secs(3); + let options = WebpageOptions { + allow_insecure: false, + follow_location: false, + max_redirections: 0, + timeout: Duration::from_secs(3), + useragent: "OpenGraph Fetcher v1.0".to_string() + }; let page = Webpage::from_url(url, options)?;