Skip to content

fix: normalize path separators for cross-platform keyword matching - #1264

Open
zad111ak-ai wants to merge 2 commits into
ajeetdsouza:mainfrom
zad111ak-ai:hermes/fix-forward-slash-matching
Open

fix: normalize path separators for cross-platform keyword matching#1264
zad111ak-ai wants to merge 2 commits into
ajeetdsouza:mainfrom
zad111ak-ai:hermes/fix-forward-slash-matching

Conversation

@zad111ak-ai

Copy link
Copy Markdown

Summary

Normalizes both stored paths and query keywords to use forward slashes before matching in filter_by_keywords. This ensures that on Windows:

  • cd bar/meow matches ~\foo\bar\meow (forward slash query → backslash path)
  • cd bar\\meow matches ~/foo/bar/meow (backslash query → forward slash path)

Both directions work because normalization is applied to both sides of the match.

Changes

  • src/db/stream.rs: Replace \\ with / in both path and keywords before rfind matching. Normalization is unconditional (no cfg!(windows)) so it's a harmless no-op on Linux/macOS and allows cross-platform test execution.
  • Added 7 new test cases covering forward/backslash matching in both directions, partial components, and mixed separators.

Comparison with PR #1222

PR #1222 normalizes only the stored path but not the query keywords. This means cd bar\\meow (backslash query) won't match a normalized path. This fix normalizes both sides.

Regression test

All 23 tests pass (15 existing + 7 new backslash-path tests + 1 add test).

Closes #1217

AI Tokens Service added 2 commits July 14, 2026 23:11
Normalize both stored paths and query keywords to use forward slashes
before matching in filter_by_keywords. This ensures that on Windows:
- cd bar/meow matches ~\foo\bar\meow
- cd bar\meow matches ~/foo/bar/meow

Unlike PR ajeetdsouza#1222 which only normalizes the path, this normalizes both
sides of the match. Normalization is unconditional (harmless no-op on
Linux/macOS) enabling cross-platform test execution.

Added 7 new test cases for backslash path matching.

Closes ajeetdsouza#1217
rustfmt requires splitting long function signatures across
multiple lines. This was the only CI failure.
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.

Match forward slashes on Windows

1 participant