How to use the rfc3986.is_valid_uri function in rfc3986

To help you get started, we’ve selected a few rfc3986 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github openstack / octavia / octavia / common / validate.py View on Github external
def url(url, require_scheme=True):
    """Raises an error if the url doesn't look like a URL."""
    try:
        if not rfc3986.is_valid_uri(url, require_scheme=require_scheme):
            raise exceptions.InvalidURL(url=url)
        p_url = rfc3986.urlparse(rfc3986.normalize_uri(url))
        if require_scheme:
            if p_url.scheme != 'http' and p_url.scheme != 'https':
                raise exceptions.InvalidURL(url=url)
    except Exception:
        raise exceptions.InvalidURL(url=url)
    return True
github openstack / nova / nova / api / validation / validators.py View on Github external
def _validate_uri(instance):
    return rfc3986.is_valid_uri(instance, require_scheme=True,
                                require_authority=True)
github frictionlessdata / tableschema-py / jsontableschema / types.py View on Github external
def cast_uri(self, value):
        if not self._type_check(value):
            return False
        if is_valid_uri(value, require_scheme=True):
            return value
        else:
            raise exceptions.InvalidURI('{0} is not a valid uri'.format(value))
github openstack / tacker / tacker / api / validation / validators.py View on Github external
def _validate_uri(instance):
    return rfc3986.is_valid_uri(instance, require_scheme=True,
                                require_authority=True)