Skip to content

Commit

Permalink
Allow single label hostname in format string
Browse files Browse the repository at this point in the history
When validating hostname format strings with module fqdn, only FQDNs
were accepted, as the minimum label length of the FQDN class is 2.
Therefore, single label hostnames like "localhost" were rejected.

Fixed this by validating with a minimum label length of 1.

Signed-off-by: Stephan Wurm <[email protected]>
  • Loading branch information
swaeberle committed Sep 15, 2023
1 parent 59e5e1d commit fa91642
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion jsonschema/_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ def is_ipv6(instance: object) -> bool:
def is_host_name(instance: object) -> bool:
if not isinstance(instance, str):
return True
return FQDN(instance).is_valid
return FQDN(instance, min_labels=1).is_valid


with suppress(ImportError):
Expand Down

0 comments on commit fa91642

Please sign in to comment.