From eafa2550bb19c1abe1620c52f73e5fc3ed92053e Mon Sep 17 00:00:00 2001 From: Hiers Date: Fri, 2 Feb 2024 21:34:45 +0000 Subject: [PATCH] Fixed not checking correctly for empty strings. --- src/main.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main.rs b/src/main.rs index 4ed2800..aed68ed 100644 --- a/src/main.rs +++ b/src/main.rs @@ -41,9 +41,8 @@ fn main() -> Result<(), ureq::Error> { let options = parse_args(); - let mut query = String::new(); let mut output = String::with_capacity(51200); /* Give output 50KiB of buffer; Should be enough to avoid reallocs*/ - query = options.query.trim().to_string().clone(); + let mut query = options.query.trim().to_string().clone(); loop { if options.interactive || options.query.trim().is_empty() { @@ -55,6 +54,7 @@ fn main() -> Result<(), ureq::Error> { /* Exit on EOF */ return Ok(()); } + query = query.trim().to_string(); } } else if query == ":" || query == ":" || query == "_" || query == "_" { return Ok(()); @@ -89,7 +89,8 @@ fn main() -> Result<(), ureq::Error> { } } else { /* Word search */ - // Do API request + + /* Do API request */ let body: Value = ureq::get(&format!(JISHO_URL!(), query)) .call()? .into_json()?;