Skip to content

Commit

Permalink
Handle dangling newlines
Browse files Browse the repository at this point in the history
  • Loading branch information
gmarraff committed Jan 22, 2024
1 parent b1f334b commit 87812d3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
4 changes: 3 additions & 1 deletion mark2confluence/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,9 @@ def get_default_parents(parents_string: str) -> List[ParentCfg]:
if not parents_string:
return []
default_parents = list()
for parent_string in parents_string.split("\n"):
parents_string_array = parents_string.split("\n")
parents_string_array = list(filter(lambda x: x, parents_string_array))
for parent_string in parents_string_array:
directory, space, parents = _parse_parent_string(parent_string)
default_parents.append(ParentCfg(directory, space, parents))
default_parents.sort(key=lambda cfg: len(cfg.directory), reverse=True)
Expand Down
1 change: 1 addition & 0 deletions tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ def test__parse_parents_string(string, expected_dir, expected_space, expected_pa
"string,expected_parents_count",
[
("tools/=foo", 1),
("tools/=foo\n", 1),
("tools/=foo\ntools/=foo", 2),
("", 0),
(None, 0)
Expand Down

0 comments on commit 87812d3

Please sign in to comment.