Skip to content

Commit 2dd1f8c

Browse files
committed
bug: bad links generated if a punctuation at the end of the link
1 parent a8c7fa6 commit 2dd1f8c

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

botaffiumeiro.py

+5-7
Original file line numberDiff line numberDiff line change
@@ -58,19 +58,17 @@ def expand_shortened_url(url: str) -> str:
5858
logger.info("Try expanding shortened URL: %s", url)
5959
# Strip trailing punctuation if present
6060
stripped_url = url.rstrip(".,")
61-
punctuation = url[
62-
len(stripped_url) :
63-
] # Store the punctuation for re-attachment if needed
6461
try:
6562
response = requests.get(
6663
stripped_url, allow_redirects=True, timeout=config_manager.TIMEOUT
6764
)
68-
expanded_url = response.url
69-
logger.info("Expanded URL %s to full link: %s", stripped_url, expanded_url)
70-
return expanded_url + punctuation
7165
except requests.RequestException:
7266
logger.exception("Error expanding shortened URL: %s", url)
73-
return url
67+
return url
68+
else:
69+
expanded_url = response.url
70+
logger.info("Expanded URL %s to full link: %s", stripped_url, expanded_url)
71+
return expanded_url
7472

7573

7674
def extract_embedded_url(query_params: dict[str, list[str]]) -> set[str]:

0 commit comments

Comments
 (0)