Skip to content

Commit

Permalink
set regex search to case-insensitive by default (BloopAI#528)
Browse files Browse the repository at this point in the history
  • Loading branch information
oppiliappan authored and calyptobai committed May 19, 2023
1 parent 57ecaec commit 7fe0f77
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions server/bleep/src/query/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ impl ExecuteQuery for FileReader {
.filter(|q| self.query_matches(q))
.filter_map(|q| {
let regex_str = q.path.as_ref()?.regex_str();
let case_insensitive = !q.case_sensitive.unwrap_or(true);
let case_insensitive = !q.is_case_sensitive();
let regex = RegexBuilder::new(&regex_str)
.case_insensitive(case_insensitive)
.build()
Expand Down Expand Up @@ -503,7 +503,7 @@ impl ExecuteQuery for RepoReader {
.filter(|q| self.query_matches(q))
.filter_map(|q| {
let regex_str = q.path.as_ref()?.regex_str();
let case_insensitive = !q.case_sensitive.unwrap_or(true);
let case_insensitive = !q.is_case_sensitive();
let regex = RegexBuilder::new(&regex_str)
.case_insensitive(case_insensitive)
.build()
Expand Down
3 changes: 2 additions & 1 deletion server/bleep/src/query/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,8 @@ impl<'a> Query<'a> {
}

pub fn is_case_sensitive(&self) -> bool {
self.case_sensitive.unwrap_or(true)
// defaults to false if unset
self.case_sensitive.unwrap_or_default()
}

fn set_global_regex(&mut self, value: Option<bool>) {
Expand Down

0 comments on commit 7fe0f77

Please sign in to comment.