Skip to content

Commit fa91642

Browse files
committed
Allow single label hostname in format string
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]>
1 parent 59e5e1d commit fa91642

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

jsonschema/_format.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ def is_ipv6(instance: object) -> bool:
274274
def is_host_name(instance: object) -> bool:
275275
if not isinstance(instance, str):
276276
return True
277-
return FQDN(instance).is_valid
277+
return FQDN(instance, min_labels=1).is_valid
278278

279279

280280
with suppress(ImportError):

0 commit comments

Comments
 (0)