Ignore tags with just whitespace (#1125)

This commit is contained in:
Pedro Lima
2025-08-10 09:20:03 +01:00
committed by GitHub
parent 6d9a694756
commit 846808d870
2 changed files with 6 additions and 1 deletions

View File

@@ -40,7 +40,7 @@ def parse_tag_string(tag_string: str, delimiter: str = ","):
return []
names = tag_string.strip().split(delimiter)
# remove empty names, sanitize remaining names
names = [sanitize_tag_name(name) for name in names if name]
names = [sanitize_tag_name(name) for name in names if name.strip()]
# remove duplicates
names = unique(names, str.lower)
names.sort(key=str.lower)

View File

@@ -40,6 +40,11 @@ class TagTestCase(TestCase):
self.assertCountEqual(
parse_tag_string("book,,movie,,,album"), ["album", "book", "movie"]
)
def test_parse_tag_string_handles_duplicate_separators_with_spaces(self):
self.assertCountEqual(
parse_tag_string("book, ,movie, , ,album"), ["album", "book", "movie"]
)
def test_parse_tag_string_replaces_whitespace_within_names(self):
self.assertCountEqual(