-
Notifications
You must be signed in to change notification settings - Fork 129
fix: convert periods to hyphens in kebab_filenames mode #424
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
Thanks @divideby0! I'll take a look at this |
|
@divideby0 -- thanks for the contribution! Note the original changes made in this area were intended to handle slash characters (for example someone might name a note "blue/green deploy.md" or "the go/no go decision.md" -- in which case we didn't want that to create a nested folder path. I'm curious why you don't actually want to preserve periods though? If I created a note named I suppose it seems to fine to replace them when kebab_filenames is true but I'm simply trying to understand further. Was there an actual bug here, or is this simply a change due to your preference in behavior? |
|
thanks for the follow-up. this issue is specifically addressing kebab cased filenames. if i have a title like |
|
I think the real problem might be that the content type of the file isn't being taken into account. If you write a note with the title "Fix for 2.0.0 Regression" then Calling I am thinking that perhaps a better thing to do would be to write a function like this: Then inside of I think that would solve your issue (though I haven't tested it), while preserving periods in the filename. Thoughts? |
Fixes basicmachines-co#423 Implements maintainer feedback to preserve periods in version numbers (e.g., "2.0.0") instead of converting them to hyphens. Uses mimetypes.guess_type() to detect real file extensions and avoid misinterpreting periods as extensions. Changes: - Add has_valid_file_extension() helper using mimetypes.guess_type() - Modify generate_permalink() to conditionally call os.path.splitext() only when real file extensions are detected - Update regex patterns to preserve periods in both CJK and non-CJK paths - Update 19 test cases to expect period preservation Examples: - "Test 3.0 Version" → test-3.0-version.md (was: test-3-0-version.md) - "Version 1.2.3 Release" → version-1.2.3-release.md 🤖 Generated with Claude Code (https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> Signed-off-by: Cedric Hurst <[email protected]>
ac90c6e to
e781f9c
Compare
|
Thanks for the feedback @bdmayes! I've updated the implementation to preserve periods in version numbers using your suggested approach with Changes MadeCore Implementation
The IssueThe root problem was that
So ResultsNow periods in version numbers are preserved:
TestsAll 19 tests passing. Updated test expectations to verify period preservation. This approach maintains semantic meaning in version numbers while still converting other characters to kebab-case format. Implementation assisted by Claude Code |
Fix for #423
Changes
generate_permalink()to preventos.path.splitext()confusionEntity.file_pathfrom@propertyto@computed_fieldso it's included inmodel_dump()Testing
New test file:
tests/mcp/test_tool_write_note_kebab_filenames.pyCoverage:
kebab_filenames=false)Results:
✅ All 1241 tests pass (19 new, no regressions)
✅ Semgrep security scan: 0 findings