in tools/yaml_parser.py [0:0]
def _assert_tag_value_is_url(self, tag_value: str) -> None:
"""Checks that `tag_value` is a valid URL as specified by the config.
Args:
tag_value: String that should be checked for being an allowed URL.
Raises:
ValueError:
- if `tag_value` is not a valid URL.
- if `tag_value` is not an HTTPS URL.
- if the config specifies a `required_domain` but the domain of
`tag_value` is unequal to that required domain.
"""
try:
result = urllib.parse.urlparse(tag_value)
except ValueError:
raise ValueError(f"{tag_value} is no valid URL.")
if result.scheme != _HTTPS_SCHEME:
raise ValueError(f"{tag_value} is not an HTTPS URL.")
if (self._url_tag_config.required_domain is not None and
self._url_tag_config.required_domain != result.netloc):
raise ValueError("URL must lead to domain "
f"{self._url_tag_config.required_domain} but is "
f"{result.netloc}.")