trim dot before checking the length

Signed-off-by: Aarush289 <cs24b064@smail.iitm.ac.in>
This commit is contained in:
Aarush289 2025-10-25 13:45:52 +05:30 committed by GitHub
parent d85260924a
commit 4de4cca71f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 2 additions and 2 deletions

View File

@ -36,10 +36,10 @@ def valid_hostname(
Returns: Returns:
True if the hostname is syntactically valid. True if the hostname is syntactically valid.
""" """
if len(host) > 253:
return False
if host.endswith("."): if host.endswith("."):
host = host[:-1] host = host[:-1]
if len(host) > 253:
return False
parts = host.split(".") parts = host.split(".")
if len(parts) < 2 and not allow_single_label: if len(parts) < 2 and not allow_single_label:
return False return False