From 2e42f7df267a1dad5a6a8b28ed51f4c463d6186f Mon Sep 17 00:00:00 2001 From: NoM1ss Date: Mon, 31 Mar 2025 23:32:27 +0800 Subject: [PATCH] Fix file processing to handle empty lines and whitespace --- src/main.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main.rs b/src/main.rs index 9fd93c7..d4041a9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -254,6 +254,7 @@ fn contains_chinese(s: &str) -> bool { } fn build_url_xpath(input: &str) -> String { + let input = input.trim(); let index = if !contains_chinese(input) {get_root_domain(input).expect("Failed to get root domain") } else { input.to_string() @@ -334,6 +335,7 @@ async fn process_file(filename: &str) -> Result<(), Box let urls: Vec = reader.lines() .map_while(Result::ok) + .filter(|line| !line.is_empty()) .map(|line| build_url_xpath(&line)) .collect();