fix: preserve dots and original case in handelize()#475
Conversation
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.
There was a problem hiding this comment.
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.
| const result = path | ||
| .replace(/___/g, '/') // Triple underscore becomes folder separator | ||
| .toLowerCase() | ||
| .split('/') | ||
| .map((segment, idx, arr) => { |
There was a problem hiding this comment.
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.
| 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 | ||
|
|
There was a problem hiding this comment.
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.md→readme.md, PROJECT_ABC_v2.0.md→project-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.
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]>
fix: preserve dots and original case in handelize()
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]>
fix: preserve dots and original case in handelize()
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.
fix: preserve dots and original case in handelize()
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]>
Summary
Two small fixes to
handelize()insrc/store.ts:topic-1773595309.753009.md→topic-1773595309-753009.md, breaking path resolution when the original file has dots..toLowerCase()call convertedMEMORY.md→memory.md, causing file-not-found errors on case-sensitive filesystems when the actual file retains uppercase.Changes
const result = path .replace(/___/g, '/') - .toLowerCase() .split('/')Test plan
topic-1773595309.753009.md) — verify paths resolve correctlyMEMORY.md,README.md) — verify case is preserved in the index