From 1dae2f42ff80dbce19149ffe629c82517208b668 Mon Sep 17 00:00:00 2001 From: RumovZ Date: Thu, 20 Jan 2022 02:57:16 +0100 Subject: [PATCH] Make `note:` and `card:` search require full match (#1606) --- rslib/src/search/sqlwriter.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rslib/src/search/sqlwriter.rs b/rslib/src/search/sqlwriter.rs index b9165abea..920afdba0 100644 --- a/rslib/src/search/sqlwriter.rs +++ b/rslib/src/search/sqlwriter.rs @@ -391,7 +391,7 @@ impl SqlWriter<'_> { } TemplateKind::Name(name) => { if is_glob(name) { - let re = format!("(?i){}", to_re(name)); + let re = format!("(?i)^{}$", to_re(name)); self.sql.push_str( "(n.mid,c.ord) in (select ntid,ord from templates where name regexp ?)", ); @@ -408,7 +408,7 @@ impl SqlWriter<'_> { fn write_notetype(&mut self, nt_name: &str) { if is_glob(nt_name) { - let re = format!("(?i){}", to_re(nt_name)); + let re = format!("(?i)^{}$", to_re(nt_name)); self.sql .push_str("n.mid in (select id from notetypes where name regexp ?)"); self.args.push(re); @@ -811,7 +811,7 @@ mod test { s(ctx, "note:basic*"), ( "(n.mid in (select id from notetypes where name regexp ?))".into(), - vec!["(?i)basic.*".into()] + vec!["(?i)^basic.*$".into()] ) );