mirror of
https://codeberg.org/rimu/pyfedi
synced 2025-02-02 16:21:32 -08:00
safer shorten_string
This commit is contained in:
parent
7efabae7b8
commit
01a235725e
1 changed files with 6 additions and 3 deletions
|
@ -284,10 +284,13 @@ def domain_from_url(url: str, create=True) -> Domain:
|
|||
|
||||
|
||||
def shorten_string(input_str, max_length=50):
|
||||
if len(input_str) <= max_length:
|
||||
return input_str
|
||||
if input_str:
|
||||
if len(input_str) <= max_length:
|
||||
return input_str
|
||||
else:
|
||||
return input_str[:max_length - 3] + '…'
|
||||
else:
|
||||
return input_str[:max_length - 3] + '…'
|
||||
return ''
|
||||
|
||||
|
||||
def shorten_url(input: str, max_length=20):
|
||||
|
|
Loading…
Add table
Reference in a new issue