Skip to content

Commit ac90c6e

Browse files
divideby0claude
andcommitted
fix: convert periods to hyphens in kebab_filenames mode
Fixes #423 - Replace periods with hyphens before calling generate_permalink() to prevent os.path.splitext() confusion - Convert Entity.file_path from @Property to @computed_field so it's included in model_dump() - Add comprehensive test suite with 19 tests covering all kebab-case transformations 🤖 Generated with Claude Code (https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 099c334 commit ac90c6e

File tree

2 files changed

+398
-3
lines changed

2 files changed

+398
-3
lines changed

src/basic_memory/schemas/base.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
from annotated_types import MinLen, MaxLen
2222
from dateparser import parse
2323

24-
from pydantic import BaseModel, BeforeValidator, Field, model_validator
24+
from pydantic import BaseModel, BeforeValidator, Field, model_validator, computed_field
2525

2626
from basic_memory.config import ConfigManager
2727
from basic_memory.file_utils import sanitize_for_filename, sanitize_for_folder
@@ -232,12 +232,16 @@ def safe_title(self) -> str:
232232
use_kebab_case = app_config.kebab_filenames
233233

234234
if use_kebab_case:
235-
fixed_title = generate_permalink(file_path=fixed_title, split_extension=False)
235+
# Replace periods with hyphens first to prevent os.path.splitext from treating them as extensions
236+
# This is necessary because generate_permalink was designed for file paths, not bare titles
237+
fixed_title = fixed_title.replace('.', '-')
238+
fixed_title = generate_permalink(file_path=fixed_title, split_extension=True)
236239

237240
return fixed_title
238241

242+
@computed_field
239243
@property
240-
def file_path(self):
244+
def file_path(self) -> str:
241245
"""Get the file path for this entity based on its permalink."""
242246
safe_title = self.safe_title
243247
if self.content_type == "text/markdown":

0 commit comments

Comments
 (0)