fix(katana): proper check for ascii alphanumeric

This commit is contained in:
tretrauit 2024-01-24 00:34:44 +07:00
parent 43a869660f
commit 9609e1b217

View File

@ -211,6 +211,9 @@ fn regexify_text(text: &String) -> String {
} }
prev_chars.push(c); prev_chars.push(c);
} }
if ascii_text.ends_with(|c: char| c.is_ascii_digit()) {
ascii_text.pop();
}
// Filter for short string. // Filter for short string.
if short_text && !ascii_text.contains(|c: char| c.is_whitespace()) { if short_text && !ascii_text.contains(|c: char| c.is_whitespace()) {
regex.push_str("^"); regex.push_str("^");
@ -275,7 +278,11 @@ fn regexify_text(text: &String) -> String {
} }
} else { } else {
// Do not push word boundary if the word contains special characters like "!" // Do not push word boundary if the word contains special characters like "!"
if processed_word.contains(|c: char| c.is_ascii_alphanumeric()) { trace!("Current processed word: {}", processed_word);
if processed_word
.chars()
.all(|c| c.is_ascii_alphanumeric())
{
regex.push_str(format!("\\b{}\\b", &processed_word.as_str()).as_str()); regex.push_str(format!("\\b{}\\b", &processed_word.as_str()).as_str());
} else { } else {
regex.push_str(format!("{}", &processed_word.as_str()).as_str()); regex.push_str(format!("{}", &processed_word.as_str()).as_str());