Skip to content

Fix quote matching in meeting name search - #31

Merged
sblack4 merged 3 commits into
mainfrom
fix/28-smart-regex-quotes
May 25, 2026
Merged

Fix quote matching in meeting name search#31
sblack4 merged 3 commits into
mainfrom
fix/28-smart-regex-quotes

Conversation

@sblack4

@sblack4 sblack4 commented Feb 15, 2026

Copy link
Copy Markdown
Collaborator

Fixes code4recovery/oiaa-direct#28

Problem

Search doesn't match meeting names when the only difference is between straight quotes (" or ') and curly quotes ("" or ''). For example, searching for "Joe's Place" wouldn't match "Joe's Place" in the database.

Solution

Transform search queries to match both straight and curly quote variants using character classes in regex patterns.

Implementation

  • Add makeQuoteFlexibleRegex() function that:
    • Escapes regex special characters
    • Replaces quotes with character classes (e.g., Joe'sJoe['']s)
  • Update pipelineFromQuery to transform nameQuery before regex matching
  • Add test cases for quote handling and regex escaping

Example

  • User searches: Joe's (straight apostrophe)
  • Backend creates regex: Joe['']s
  • Matches both: Joe's (straight) and Joe's (curly) ✓

Benefits

  • ✅ No database migration required
  • ✅ Works with existing data immediately
  • ✅ Simple, focused change
  • ✅ Easy to rollback if needed

Testing

  • Added unit tests for quote transformation
  • Existing tests still pass (simple strings unchanged)

Transform search queries to match both straight and curly quote variants
using character classes in regex patterns. This fixes issue #28 where
searching "Joe's Place" wouldn't match "Joe's Place" in the database.

Implementation:
- Add makeQuoteFlexibleRegex() to escape special chars and convert
  quotes to character classes (e.g., "Joe's" → "Joe['']s")
- Update pipelineFromQuery to use the new function for nameQuery
- Add test cases for quote handling and regex escaping

No database changes required. Works with existing data.

Fixes code4recovery/oiaa-direct#28
Keep inline regex explanations, drop JSDoc and standalone comments.
@sblack4
sblack4 requested a review from tim-rohrer March 1, 2026 20:32

@tim-rohrer tim-rohrer left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any idea why the version in package-lock.json updated? Not that it is wrong, but it seems odd that some contributions lead to the file being updated, and others don't.

Previous version had character classes like `['']` and `[""]` where both
inner chars were ASCII — visually rendered as if curly via editor font,
but the bytes were duplicate U+0027 / U+0022. Regex deduped to plain
straight quote, so curly variants were never matched.

Use explicit ‘’ / “” escapes so source bytes are
unambiguous. Add stringUtils.spec.ts exercising real RegExp.test()
behavior on both quote variants (the original tests only compared
pattern strings, which couldn't catch this).

Remove two pipelineFromQuery tests now redundant with stringUtils.spec
and pre-existing nameQuery wiring tests.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@sblack4

sblack4 commented May 23, 2026

Copy link
Copy Markdown
Collaborator Author

Update before merging — caught a bug in my own work:

The character classes I wrote ([''] / [""]) rendered as straight+curly in my editor but were actually duplicate ASCII bytes (5b 27 27 5d / 5b 22 22 5d). Regex dedupes those, so the function was effectively a no-op for curly input. The tests I added didn't catch it because they asserted toStrictEqual on pattern strings — both sides had matching ASCII bytes, so the test agreed with the broken implementation.

Commit 94eb178 fixes this:

  • stringUtils.ts now uses explicit ‘’ / “” escapes — source bytes are unambiguous regardless of font/autocorrect.
  • New stringUtils.spec.ts exercises real RegExp.test() behavior on both quote variants — would catch this class of bug.
  • Removed two pipeline-level tests that were either the broken no-op assertion or redundant with the new spec / existing nameQuery wiring tests.

Re: the package-lock.json version bumppackage.json on main is already at 0.16.0-alpha (commit 74087c6); the lockfile had drifted to 0.4.0-alpha. npm install during this PR synced it. Unrelated to the fix itself, harmless side effect.

@sblack4
sblack4 merged commit 892d156 into main May 25, 2026
@sblack4
sblack4 deleted the fix/28-smart-regex-quotes branch May 25, 2026 00:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Search should ignore differences between straight and curly quotes

2 participants