Fixed not checking correctly for empty strings.

This commit is contained in:
Hiers 2024-02-02 21:34:45 +00:00
parent 19929580da
commit eafa2550bb

View file

@ -41,9 +41,8 @@ fn main() -> Result<(), ureq::Error> {
let options = parse_args(); 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*/ 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 { loop {
if options.interactive || options.query.trim().is_empty() { if options.interactive || options.query.trim().is_empty() {
@ -55,6 +54,7 @@ fn main() -> Result<(), ureq::Error> {
/* Exit on EOF */ /* Exit on EOF */
return Ok(()); return Ok(());
} }
query = query.trim().to_string();
} }
} else if query == ":" || query == "" || query == "_" || query == "_" { } else if query == ":" || query == "" || query == "_" || query == "_" {
return Ok(()); return Ok(());
@ -89,7 +89,8 @@ fn main() -> Result<(), ureq::Error> {
} }
} else { /* Word search */ } else { /* Word search */
// Do API request
/* Do API request */
let body: Value = ureq::get(&format!(JISHO_URL!(), query)) let body: Value = ureq::get(&format!(JISHO_URL!(), query))
.call()? .call()?
.into_json()?; .into_json()?;