@bobfrankston/rmfmail 1.1.110 → 1.1.112

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2704,6 +2704,13 @@ export class MailxDB {
2704
2704
  const tokens = query.split(/\s+/).filter(Boolean);
2705
2705
  const firstSubstr = `%${tokens[0]}%`;
2706
2706
  const firstPrefix = `${tokens[0]}%`;
2707
+ // Word-prefix patterns: the token at the start of ANY name word, not
2708
+ // just the whole name. Catches "Frankston, Bob" / "Frankston,Bob"
2709
+ // when the user types "bob" — a first-name match on a Last,First
2710
+ // contact (Bob 2026-05-21). The space variant also covers the normal
2711
+ // "Bob Frankston" middle/last-word case.
2712
+ const firstWordSpace = `% ${tokens[0]}%`;
2713
+ const firstWordComma = `%,${tokens[0]}%`;
2707
2714
  const tokenWhere = tokens.map(() => "(name LIKE ? OR email LIKE ?)").join(" AND ");
2708
2715
  const tokenParams: string[] = [];
2709
2716
  for (const t of tokens) { tokenParams.push(`%${t}%`, `%${t}%`); }
@@ -2725,7 +2732,7 @@ export class MailxDB {
2725
2732
  rows = this.db.prepare(
2726
2733
  `SELECT name, email, source, use_count, last_used,
2727
2734
  (CASE
2728
- WHEN lower(name) LIKE lower(?) THEN 300
2735
+ WHEN lower(name) LIKE lower(?) OR lower(name) LIKE lower(?) OR lower(name) LIKE lower(?) THEN 300
2729
2736
  WHEN substr(email, 1, instr(email, '@') - 1) LIKE lower(?) THEN 200
2730
2737
  WHEN email LIKE ? OR name LIKE ? THEN 100
2731
2738
  ELSE 0
@@ -2739,7 +2746,7 @@ export class MailxDB {
2739
2746
  WHERE ${tokenWhere}
2740
2747
  ORDER BY match_rank DESC, use_count DESC, last_used DESC
2741
2748
  LIMIT ?`
2742
- ).all(firstPrefix, firstPrefix, firstSubstr, firstSubstr, ...tokenParams, limit * 2) as any[];
2749
+ ).all(firstPrefix, firstWordSpace, firstWordComma, firstPrefix, firstSubstr, firstSubstr, ...tokenParams, limit * 2) as any[];
2743
2750
  } catch (e: any) {
2744
2751
  console.error(` [searchContacts] ranked query failed (${e?.message}) — falling back to simple LIKE`);
2745
2752
  rows = this.db.prepare(