Fails to validate URL for local file: ```Python from validators import url url("file:///var/www") # ValidationError(func=url, args={'value': 'file:///var/www'}) ``` Excpected `True`, because this URL type standartizated in **RFC 8089**. Error in `_validate_netloc()` function. It expected domain like _var.com_, but see directory _var_. ```Python ValidationError( func=hostname, args={'value': 'var', 'skip_ipv6_addr': True, 'skip_ipv4_addr': False, 'may_have_port': True, 'maybe_simple': False, 'consider_tld': False, 'private': None, 'rfc_1034': False, 'rfc_2782': False} ) ``` May be we should skip netloc validation in some cases like `file` and add `file` scheme in `_validate_scheme()` function. Works this code, but is it correct behaviour for common URL scheme? ```Python from validators import url url("file:///var/www", simple_host = True, validate_scheme = lambda x: x == "file") # True ```
Activity
fix: validate file URIs per RFC 8089 (issue python-validators#481)
nandgator commentedon Oct 10, 2026
Fixed by #483:
url()now acceptsfile://URLs per RFC 8089 (an empty authority orlocalhost). Thanks for the report!