diff --git a/src/validators/url.py b/src/validators/url.py index 30b7b02..5cbe389 100644 --- a/src/validators/url.py +++ b/src/validators/url.py @@ -3,7 +3,7 @@ # standard from functools import lru_cache import re -from typing import Optional +from typing import Callable, Optional from urllib.parse import parse_qs, unquote, urlsplit # local @@ -165,6 +165,7 @@ def url( private: Optional[bool] = None, # only for ip-addresses rfc_1034: bool = False, rfc_2782: bool = False, + validate_scheme: Callable[[str], bool] = _validate_scheme, ): r"""Return whether or not given value is a valid URL. @@ -213,6 +214,8 @@ def url( rfc_2782: Domain/Host name is of type service record. Ref: [RFC 2782](https://www.rfc-editor.org/rfc/rfc2782). + validate_scheme: + Function that validates URL scheme. Returns: (Literal[True]): If `value` is a valid url. @@ -229,7 +232,7 @@ def url( return False return ( - _validate_scheme(scheme) + validate_scheme(scheme) and _validate_netloc( netloc, skip_ipv6_addr,