Skip to content

Commit 8caeb7e

Browse files
committed
Fix issue #70: Properly handle stripping of # characters in tags
The tags need to be properly handled when parsing to ensure the # characters are stripped correctly. We need to first strip whitespace with strip(), and then strip the # characters with lstrip('#'). This fixes the issue where tags would accumulate # characters during multiple edits. Signed-off-by: phernandez <paul@basicmachines.co>
1 parent 50409e5 commit 8caeb7e

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/basic_memory/utils.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,13 +148,13 @@ def parse_tags(tags: Union[List[str], str, None]) -> List[str]:
148148

149149
# Process list of tags
150150
if isinstance(tags, list):
151-
# Strip leading '#' characters from each tag to prevent accumulation
152-
return [tag.lstrip('#').strip() for tag in tags if tag and tag.strip()]
151+
# First strip whitespace, then strip leading '#' characters to prevent accumulation
152+
return [tag.strip().lstrip('#') for tag in tags if tag and tag.strip()]
153153

154154
# Process comma-separated string of tags
155155
if isinstance(tags, str):
156-
# Split by comma and strip leading '#' characters
157-
return [tag.lstrip('#').strip() for tag in tags.split(",") if tag and tag.strip()]
156+
# Split by comma, strip whitespace, then strip leading '#' characters
157+
return [tag.strip().lstrip('#') for tag in tags.split(",") if tag and tag.strip()]
158158

159159
# For any other type, try to convert to string and parse
160160
try: # pragma: no cover

0 commit comments

Comments
 (0)