Escape backslashes in fuzzy_search (#4462)
* Escape backslashes in fuzzy_search * Update utils.rs
This commit is contained in:
parent
ae62ef2b7e
commit
d79502dff3
1 changed files with 5 additions and 1 deletions
|
@ -236,7 +236,11 @@ impl<T: LimitDsl> LimitDsl for Commented<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn fuzzy_search(q: &str) -> String {
|
pub fn fuzzy_search(q: &str) -> String {
|
||||||
let replaced = q.replace('%', "\\%").replace('_', "\\_").replace(' ', "%");
|
let replaced = q
|
||||||
|
.replace('\\', "\\\\")
|
||||||
|
.replace('%', "\\%")
|
||||||
|
.replace('_', "\\_")
|
||||||
|
.replace(' ', "%");
|
||||||
format!("%{replaced}%")
|
format!("%{replaced}%")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue