Skip to content

Commit

Permalink
Additional comments and spelling corrections for util functions
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeylockwood committed Nov 6, 2024
1 parent ebff654 commit 234ab24
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion web/domains/case/export/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -947,5 +947,5 @@ def _normalize_address(address: str) -> str:
# Strip trailing comma
address = address.rstrip(",")

# Replace comma without a following whitespace charatcer with a comma and a space
# Replace comma without a following whitespace character with a comma and a space
return re.sub(r",(?=\S)", ", ", address)
5 changes: 5 additions & 0 deletions web/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,13 @@ def newlines_to_commas(field: str) -> str:
"123 Sesame St\nSesame Land\n\nSesame" -> "123 Sesame St, Sesame Land, Sesame"
"123 Sesame St,\nSesame Land,\n\n Sesame" -> "123 Sesame St, Sesame Land, Sesame"
"""
# Replace all newlines with commas. Strip all spaces and commas before the newline
field = re.sub(r"(\s+)?(,)?(\s+)?(\n+)", ", ", field.strip())

# Replace all whitespace with a single space and strip commas from the ends of the text
field = clean_whitespace(field.strip(","))

# Replace double commas and commas separated by a space with a single comma
return re.sub(r"(,)(( ,)+|(,)+)", ",", field)


Expand Down

0 comments on commit 234ab24

Please sign in to comment.