-
Notifications
You must be signed in to change notification settings - Fork 261
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ui): Normallize strings when doing fuzzy matching.
- Loading branch information
Showing
5 changed files
with
75 additions
and
23 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,21 @@ | ||
mod fuzzy_match_room_name; | ||
|
||
pub use fuzzy_match_room_name::new_filter as new_filter_fuzzy_match_room_name; | ||
use unicode_normalization::{char::is_combining_mark, UnicodeNormalization}; | ||
|
||
fn normalize_string(str: &str) -> String { | ||
str.nfd().filter(|c| !is_combining_mark(*c)).collect::<String>() | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use super::*; | ||
|
||
#[test] | ||
fn test_normalize_string() { | ||
assert_eq!(&normalize_string("abc"), "abc"); | ||
assert_eq!(&normalize_string("Ștefan Été"), "Stefan Ete"); | ||
assert_eq!(&normalize_string("Ç ṩ ḋ Å"), "C s d A"); | ||
assert_eq!(&normalize_string("هند"), "هند"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters