diff --git a/plugins/module_utils/client.py b/plugins/module_utils/client.py index 764f0772..e7cc027e 100644 --- a/plugins/module_utils/client.py +++ b/plugins/module_utils/client.py @@ -10,6 +10,7 @@ __metaclass__ = type import json +import re from urllib.error import HTTPError, URLError from urllib.parse import ParseResult, urlencode, urlparse @@ -50,11 +51,6 @@ def __init__( timeout: Optional[Any] = None, validate_certs: Optional[Any] = None, ) -> None: - if not (host or "").startswith(("https://", "http://")): - raise EDAHTTPError( - f"Invalid instance host value: '{host}'. " - "Value must start with 'https://' or 'http://'" - ) self.host = host self.username = username @@ -62,6 +58,10 @@ def __init__( self.timeout = timeout self.validate_certs = validate_certs + # Perform some basic validation + if not re.match("^https{0,1}://", self.host): + self.host = f"https://{0}" + # Try to parse the hostname as a url try: self.url = urlparse(self.host)