From 6b098702c6f7df5d400b76031618506dbdda02a5 Mon Sep 17 00:00:00 2001 From: Miquel Sabaté Solà Date: Tue, 12 Aug 2025 09:36:10 +0200 Subject: Trim word parts on database insert MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Miquel Sabaté Solà --- crates/cli/src/words.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'crates') diff --git a/crates/cli/src/words.rs b/crates/cli/src/words.rs index d387f00..ba86041 100644 --- a/crates/cli/src/words.rs +++ b/crates/cli/src/words.rs @@ -206,6 +206,7 @@ fn ask_for_word_based_on(enunciated: String, word: Word) -> Result else { return Err("abort!".to_string()); }; + let particle = particle.trim().to_string(); let categories = vec![ Category::Unknown, @@ -261,6 +262,7 @@ fn ask_for_word_based_on(enunciated: String, word: Word) -> Result } _ => None, }; + let kind = kind.trim().to_string(); // TODO: refine guess once the inflection is known: select from possible values. let kind = match category { @@ -366,7 +368,7 @@ fn ask_for_word_based_on(enunciated: String, word: Word) -> Result // from it, and insert it into the database. fn do_create(enunciated: String) -> Result<(), String> { let mut guess = get_initial_guess(enunciated.as_str()); - guess.enunciated = enunciated.clone(); + guess.enunciated = enunciated.trim().to_string(); let word = ask_for_word_based_on(enunciated.clone(), guess)?; match mihi::create_word(word) { -- cgit v1.2.3