Skip to content

Commit

Permalink
[decksite/deck_name#file_name] add fallback if no safe characters
Browse files Browse the repository at this point in the history
previously, a deck name with no safe (i.e. ascii) characters would lead to
file_name() returning an empty string, and the downloaded file being simply
`txt`

addresses PennyDreadfulMTG#13238
  • Loading branch information
dunn committed Jan 12, 2025
1 parent 06e45eb commit 20ef4dd
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion decksite/deck_name.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,12 @@ def file_name(d: Deck) -> str:
safe_name = normalize(d).replace(' ', '-')
safe_name = re.sub('--+', '-', safe_name, flags=re.IGNORECASE)
safe_name = re.sub('[^0-9a-z-]', '', safe_name, flags=re.IGNORECASE)
return safe_name.strip('-')
safe_name = safe_name.strip('-')

if safe_name == '':
return 'untitled'
else:
return safe_name

def replace_space_alternatives(name: str) -> str:
name = name.replace('_', ' ')
Expand Down

0 comments on commit 20ef4dd

Please sign in to comment.