Skip to content

Commit

Permalink
fix empty string.
Browse files Browse the repository at this point in the history
  • Loading branch information
EdwinBetanc0urt committed Jul 16, 2024
1 parent a1739f2 commit 9e781e8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
8 changes: 5 additions & 3 deletions src/models/menu_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,11 @@ pub async fn menu_tree_from_id(_id: Option<String>, _dictionary_code: Option<&St
let mut _document = MenuTree::from_id(_id);

let mut _index_name = "menu_tree".to_string();
if _dictionary_code.is_some() {
_index_name.push_str("_");
_index_name.push_str(_dictionary_code.unwrap());
if let Some(code) = _dictionary_code {
if !code.trim().is_empty() {
_index_name.push_str("_");
_index_name.push_str(code);
}
}
log::info!("Index to search {:}", _index_name);

Expand Down
6 changes: 4 additions & 2 deletions src/models/role.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,10 @@ pub async fn role_from_id(_id: Option<&String>, _client_id: Option<&String>, _di
}

async fn get_index_name(_client_id: Option<&String>) -> Result<String, std::io::Error> {
if _client_id.is_none() {
return Err(Error::new(ErrorKind::InvalidData.into(), "Client is Mandatory"));
if _client_id.is_none() || _client_id.as_deref().map_or(false, |s| s.trim().is_empty()) {
return Err(
Error::new(ErrorKind::InvalidData.into(), "Client is Mandatory")
);
}

let _base_index: String = "role".to_string();
Expand Down

0 comments on commit 9e781e8

Please sign in to comment.