Skip to content

fix: preserve dots and original case in handelize()#475

Merged
tobi merged 2 commits intotobi:mainfrom
alexei-led:fix/handelize-dots-and-case
Mar 28, 2026
Merged

fix: preserve dots and original case in handelize()#475
tobi merged 2 commits intotobi:mainfrom
alexei-led:fix/handelize-dots-and-case

Conversation

@alexei-led
Copy link
Copy Markdown
Contributor

Summary

Two small fixes to handelize() in src/store.ts:

  • Preserve dots in filenames: The regex replaced all non-letter/non-number chars with dashes, including dots in the filename stem. This mangled filenames like topic-1773595309.753009.mdtopic-1773595309-753009.md, breaking path resolution when the original file has dots.
  • Preserve original filename case: The blanket .toLowerCase() call converted MEMORY.mdmemory.md, causing file-not-found errors on case-sensitive filesystems when the actual file retains uppercase.

Changes

- .replace(/[^\p{L}\p{N}$]+/gu, '-')
+ .replace(/[^\p{L}\p{N}.$]+/gu, '-')
  const result = path
    .replace(/___/g, '/')
-   .toLowerCase()
    .split('/')

Test plan

  • Index a collection containing files with dots in names (e.g. topic-1773595309.753009.md) — verify paths resolve correctly
  • Index a collection with uppercase filenames (e.g. MEMORY.md, README.md) — verify case is preserved in the index

The handelize() regex replaced all non-letter/non-number chars with
dashes, including dots in the filename stem. This mangled session
filenames like "topic-1773595309.753009.md" to "topic-1773595309-753009.md",
breaking memory_get path resolution (file not found on disk).

Fix: add dot to the preserved character class in the filename regex.
After deploying, run qmd-reindex.sh to rebuild indexes with correct paths.
Copilot AI review requested due to automatic review settings March 27, 2026 13:55
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates handelize() path normalization to avoid breaking file lookup on case-sensitive filesystems and for filenames containing dots, improving the stability of indexing/path resolution.

Changes:

  • Stop lowercasing the input path so the generated handle preserves original case.
  • Preserve . in the filename stem (last path segment) while still dash-normalizing other characters.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/store.ts
Comment on lines 1596 to 1599
const result = path
.replace(/___/g, '/') // Triple underscore becomes folder separator
.toLowerCase()
.split('/')
.map((segment, idx, arr) => {
Copy link

Copilot AI Mar 27, 2026

Choose a reason for hiding this comment

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

The JSDoc for handelize() still states it "Convert[s] to lowercase", but .toLowerCase() was removed. Please update the docstring (and any related bullet points) to match the new case-preserving behavior so callers/tests don’t rely on outdated semantics.

Copilot uses AI. Check for mistakes.
Comment thread src/store.ts
Comment on lines 1611 to 1614
const cleanedName = nameWithoutExt
.replace(/[^\p{L}\p{N}$]+/gu, '-') // Keep route marker "$", dash-separate other chars
.replace(/[^\p{L}\p{N}.$]+/gu, '-') // Keep letters, numbers, dots, "$"; dash-separate rest
.replace(/^-+|-+$/g, ''); // Remove leading/trailing dashes

Copy link

Copilot AI Mar 27, 2026

Choose a reason for hiding this comment

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

This change alters handelize() output (case is no longer normalized and dots are now preserved in the filename stem), but existing unit tests assert lowercasing and dot→dash conversion (e.g. README.mdreadme.md, PROJECT_ABC_v2.0.mdproject-abc-v2-0.md). Please update the tests and add explicit cases for the reported regressions (e.g. topic-1773595309.753009.md and MEMORY.md) to prevent future breakage.

Copilot uses AI. Check for mistakes.
@tobi tobi merged commit 2ec3360 into tobi:main Mar 28, 2026
3 of 4 checks passed
tobi added a commit that referenced this pull request Mar 28, 2026
PR #475 changed handelize() to preserve original case and dots,
but the tests still expected lowercase output. Update assertions
to match the new behavior.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
jaylfc added a commit to jaylfc/qmd that referenced this pull request Apr 5, 2026
fix: preserve dots and original case in handelize()
jaylfc added a commit to jaylfc/qmd that referenced this pull request Apr 5, 2026
PR tobi#475 changed handelize() to preserve original case and dots,
but the tests still expected lowercase output. Update assertions
to match the new behavior.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
jaylfc added a commit to jaylfc/qmd that referenced this pull request Apr 5, 2026
fix: preserve dots and original case in handelize()
jaylfc added a commit to jaylfc/qmd that referenced this pull request Apr 5, 2026
PR tobi#475 changed handelize() to preserve original case and dots,
but the tests still expected lowercase output. Update assertions
to match the new behavior.
tanarchytan referenced this pull request in tanarchytan/lotl Apr 8, 2026
fix: preserve dots and original case in handelize()
tanarchytan referenced this pull request in tanarchytan/lotl Apr 8, 2026
PR #475 changed handelize() to preserve original case and dots,
but the tests still expected lowercase output. Update assertions
to match the new behavior.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
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.

3 participants