fix: Sanitize filenames and allow optional kebab case#260
Conversation
|
|
||
|
|
||
| def generate_permalink(file_path: Union[Path, str, PathLike]) -> str: | ||
| def generate_permalink(file_path: Union[Path, str, PathLike], split_extension: bool = True) -> str: |
There was a problem hiding this comment.
Most modifications in this file are simply lint fixes, applied automatically on save in my IDE.
The main changes are:
- adding the optional
split_extensionparameter - retaining the file extension in a variable
- appending the extension back into the returned string, when applicable
Doing so allows this function to be reused, keeping things DRY, rather than repeating almost the entire function for use when generating titles.
There was a problem hiding this comment.
re: lint fixes. As long as ruff is happy.
phernandez
left a comment
There was a problem hiding this comment.
this is a good addition. I think we should add an integration test that uses the client to call a note that needs the safe_title formatting and assert BM does everything correctly.
See test-int/mcp/test_write_note_integration.py
| if use_kebab_case: | ||
| fixed_title = generate_permalink(file_path=fixed_title, split_extension=False) | ||
|
|
||
| return fixed_title |
There was a problem hiding this comment.
I think we'll need to do the same for project names. A project named "Hi/There" will fail to be found by the remove_project tool. Even if escaped, the project name when passed to the FastApi endpoint will confuse FastApi and return 404.
|
|
||
|
|
||
| def generate_permalink(file_path: Union[Path, str, PathLike]) -> str: | ||
| def generate_permalink(file_path: Union[Path, str, PathLike], split_extension: bool = True) -> str: |
There was a problem hiding this comment.
re: lint fixes. As long as ruff is happy.
Totally. I actually spent quite some time mocking out the config in a unit test to get that working. I guess that was lost in the shuffle of merge conflicts when rebasing a few times? Either way, an integration test is a better option so I'll add that. |
45bddbe to
7b3d710
Compare
Signed-off-by: Brandon Mayes <5610870+bdmayes@users.noreply.github.com>
Signed-off-by: Brandon Mayes <5610870+bdmayes@users.noreply.github.com>
7b3d710 to
cdbbad1
Compare
Fix for #154
Falseas the default in order to maintain backward compatibility for existing users. Can be overridden toTrueif desired.Replaces: #160