Don't show ellipsis when URL shortening only removed scheme (#427)

This commit is contained in:
Michael Manfre 2023-01-16 14:27:25 -05:00 committed by GitHub
parent fd9015a7c5
commit 333317875b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 4 deletions

View File

@ -107,12 +107,14 @@ def shorten_link_text(attrs, new=False):
if not text:
text = attrs.get((None, "href"))
if text and "://" in text and len(text) > 30:
attrs[(None, "class")] = " ".join(
filter(None, [attrs.pop((None, "class"), ""), "ellipsis"])
)
text = text.split("://", 1)[-1]
attrs["_text"] = text[:30]
if len(text) > 30:
attrs[(None, "class")] = " ".join(
filter(None, [attrs.pop((None, "class"), ""), "ellipsis"])
)
# Add the full URL in to title for easier user inspection
attrs[(None, "title")] = attrs.get((None, "href"))
attrs["_text"] = text.split("://", 1)[-1][:30]
return attrs