From: Greg Burri Date: Wed, 15 Jan 2025 09:49:46 +0000 (+0100) Subject: Forced lower case tags X-Git-Url: https://git.euphorik.ch/?a=commitdiff_plain;h=54989f3212837ff9ce1f8836e4a370cba9504b29;p=recipes.git Forced lower case tags --- diff --git a/backend/src/services/ron.rs b/backend/src/services/ron.rs index 28e9a9b..71e0635 100644 --- a/backend/src/services/ron.rs +++ b/backend/src/services/ron.rs @@ -253,7 +253,15 @@ pub async fn add_tags( ExtractRon(ron): ExtractRon, ) -> Result { check_user_rights_recipe(&connection, &user, ron.recipe_id).await?; - connection.add_recipe_tags(ron.recipe_id, &ron.tags).await?; + connection + .add_recipe_tags( + ron.recipe_id, + &ron.tags + .into_iter() + .map(|tag| tag.to_lowercase()) + .collect::>(), + ) + .await?; Ok(StatusCode::OK) } diff --git a/frontend/src/recipe_edit.rs b/frontend/src/recipe_edit.rs index 9f5f721..5b8535c 100644 --- a/frontend/src/recipe_edit.rs +++ b/frontend/src/recipe_edit.rs @@ -184,7 +184,8 @@ pub fn setup_page(recipe_id: i64) -> Result<(), JsValue> { fn add_tags(recipe_id: i64, tags: String) { spawn_local(async move { - let tag_list: Vec = tags.split_whitespace().map(String::from).collect(); + let tag_list: Vec = + tags.split_whitespace().map(str::to_lowercase).collect(); if !tag_list.is_empty() { let body = ron_api::Tags { recipe_id,