Validate URL is valid

    NOTE: only support http & https
495233
def validate_url(url):
    
    schemes = ['http', 'https']
    netloc_re = re.compile(
        r'^'
        r'(?:\S+(?::\S*)?@)?'  # user:pass auth
        r'(?:[a-z0-9]|[a-z0-9][a-z0-9\-]{0,61}[a-z0-9])'
        r'(?:\.(?:[a-z0-9]|[a-z0-9][a-z0-9\-]{0,61}[a-z0-9]))*'  # host
        r'(?::[0-9]{2,5})?'  # port
        r'$', re.IGNORECASE
    )

    try:
        scheme, netloc, path, query, fragment = urlsplit(url)
    except ValueError:
        raise Invalid('Invalid URL')

    if scheme not in schemes:
        raise Invalid('Missing URL scheme')

    if not netloc_re.search(netloc):
        raise Invalid('Invalid URL')

    return url
1101526
def valid_url(x: str) -> bool:
    
    if isinstance(x, str) and re.match(URL_PATTERN, x):
        return True
    else:
        return False
939309
function supportsSSL()
    {
        $v = curl_version();
        if(is_array($v)) {
            return in_array('https', $v['protocols']);
        } elseif (is_string($v)) {
            return preg_match('/OpenSSL/i', $v);
        } else {
            return 0;
        }
    }
100824
def __isValidUrl(self, addr):
        
        regex = re.compile(
            r'^(?:http)s?://'  #: http:// or https://
            r'(?:(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+(?:[A-Z]{2,6}\.?|[A-Z0-9-]{2,}\.?)|'  #: domain...
            r'localhost|'  #: localhost...
            r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})'  #: ...or ip
            r'(?::\d+)?'  #: optional port
            r'(?:/?|[/?]\S+)$', re.IGNORECASE)
        if addr and isinstance(addr, string_types):
            if regex.match(addr):
                return True
        return False
391969
function correctHttpAndHttps(url) {
	var baseURL = url;

	// Check if http:// is correct
	if (new RegExp('^http://').test(baseURL)) {
		// Do nothing

	} else {
		// Check if https:// is correct
		if (new RegExp('^https://').test(baseURL)) {
			// Do nothing

		} else {
			// http:// or https:// is not set correct

			// Replace protocol mistakes like 'ttp://' to 'http://'
			var testHttp01 = new RegExp('^ttp://');
			if (testHttp01.test(baseURL)) {
				baseURL = baseURL.replace(testHttp01, 'http://')
			} else {
				var testHttp02 = new RegExp('^tp://');
				if (testHttp02.test(baseURL)) {
					baseURL = baseURL.replace(testHttp02, 'http://')
				} else {
					var testHttp03 = new RegExp('^p://');
					if (testHttp03.test(baseURL)) {
						baseURL = baseURL.replace(testHttp03, 'http://')
					} else {
						var testHttp04 = new RegExp('^://');
						if (testHttp04.test(baseURL)) {
							baseURL = baseURL.replace(testHttp04, 'http://')
						} else {
							var testHttp05 = new RegExp('^//');
							if (testHttp05.test(baseURL)) {
								baseURL = baseURL.replace(testHttp05, 'http://')
							} else {
								var testHttp06 = new RegExp('^/');
								if (testHttp06.test(baseURL)) {
									baseURL = baseURL.replace(testHttp06, 'http://')
								} else {
									var testHttps01 = new RegExp('^ttps://');
									if (testHttps01.test(baseURL)) {
										baseURL = baseURL.replace(testHttps01, 'https://')
									} else {
										var testHttps02 = new RegExp('^tps://');
										if (testHttps02.test(baseURL)) {
											baseURL = baseURL.replace(testHttps02, 'https://')
										} else {
											var testHttps03 = new RegExp('^ps://');
											if (testHttps03.test(baseURL)) {
												baseURL = baseURL.replace(testHttps03, 'https://')
											} else {
												var testHttps04 = new RegExp('^s://');
												if (testHttps04.test(baseURL)) {
													baseURL = baseURL.replace(testHttps04, 'https://')
												} else {
													var testHttp07 = new RegExp('^.');
													if (testHttp07.test(baseURL)) {
														baseURL = 'http://' + baseURL;
													} else {
														// Other mistakes
													}
												}
											}
										}
									}
								}
							}
						}
					}
				}
			}
		}
	}

	return baseURL;
}
414491
function(url) {
    var protocol;
    if (url.indexOf('http://') !== -1) {
      protocol = http;
    } else if (url.indexOf('https://') !== -1) {
      protocol = https;
    } else {
      throw new Error('unsupported protocol :' + url);
    }

    return protocol;
  }
106381
def validate(filename, verbose=False):
    
    # is_css = filename.endswith(".css")

    is_remote = filename.startswith("http://") or filename.startswith(
        "https://")
    with tempfile.TemporaryFile() if is_remote else open(
            filename, "rb") as f:

        if is_remote:
            r = requests.get(filename, verify=False)
            f.write(r.content)
            f.seek(0)

        # if is_css:
        #     cmd = (
        #         "curl -sF \"file=@%s;type=text/css\" -F output=json -F warning=0 %s"
        #         % (quoted_filename, CSS_VALIDATOR_URL))
        #     _ = cmd
        # else:
        r = requests.post(
            HTML_VALIDATOR_URL,
            files={"file": (filename, f, "text/html")},
            data={
                "out": "json",
                "showsource": "yes",
            },
            verify=False)

    return r.json()
51762
def url(self, url):
        
        if url is None:
            raise ValueError("Invalid value for `url`, must not be `None`")
        if url is not None and len(url) > 4096:
            raise ValueError("Invalid value for `url`, length must be less than or equal to `4096`")
        if url is not None and len(url) < 1:
            raise ValueError("Invalid value for `url`, length must be greater than or equal to `1`")
        if url is not None and not re.search('^https?:.*', url):
            raise ValueError("Invalid value for `url`, must be a follow pattern or equal to `/^https?:.*/`")

        self._url = url
1052341
def validated_url(url):
    """"""
    try:
        u = urlparse(url)
        u.port  # Trigger 'invalid port' exception
    except Exception:
        raise error.URLError(url)
    else:
        if not u.scheme or not u.netloc:
            raise error.URLError(url)
        return url
486875
function _isValid(el, currentPath) {
	// Link has no destination URL
	if (! el.href) { return false; }

	// Link opens a new browser window
	if (el.target === '_blank') { return false; }

	// Link is not absolute URL
	if (! /https?:/.test(el.href)) { return false; }

	// Link is a download
	if (el.hasAttribute('download')) { return false; }

	// Link is supposed to be ignored
	if (el.hasAttribute('data-static')) { return false; }

	// Link is external URL
	if (el.host && el.host !== location.host) { return false; }

	// Link is current page, but with a hash added
	if (el.hash && el.pathname === currentPath) { return false; }

	return true;
}
340270
def validate(self, value):
        ''''''
        if self.blank and value == '':
            return True
        if URIValidator.uri_regex.match(value):
            self._choice = value
            return True
        else:
            self.error_message = '%s is not a valid URI' % value
            return False
1282398
def convert_invalid_url(url):
    
    regex_valid_url = re.compile(
        r'^(?:http|ftp)s?://' # http:// or https://
        r'(?:(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+(?:[A-Z]{2,6}\.?|[A-Z0-9-]{2,}\.?)|' #domain...
        r'localhost|' #localhost...
        r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})' # ...or ip
        r'(?::\d+)?' # optional port
        r'(?:/?|[/?]\S+)$', re.IGNORECASE)

    return url if regex_valid_url.match(url) else 'http://{}'.format(url)
948886
def validate_url(cls, url):
        

        if url is None:
            return None

        url = url.strip()
        while url.endswith('/'):
            url = url[:-1]
        return url
54982
def _IsValidUrl(self, url):
    
    parsed_url = urlparse.urlparse(url)
    return parsed_url.scheme in self._SUPPORTED_URL_SCHEMES
704629
def is_valid_api_url(self, url, non_blocking=True):
        """"""
        logger.debug(str((url)))
        if non_blocking:
            method = self._is_valid_api_url
            return self._create_worker(method, url)
        else:
            return self._is_valid_api_url(url=url)
1101114
protected function _validate_url($value)
    {
        $value = trim($value);

        if ($value === '') {
            return '';
        }

        if (filter_var($value, FILTER_VALIDATE_URL) !== false) {
            $parts = explode('://', $value, 2);
            $scheme = strtolower($parts[0]);
            $path = $parts[1];
            if ($scheme !== 'http' && $scheme !== 'https') {
                return null;
            } else {
                return $scheme . '://' . $path;
            }
        } else {
            return null;
        }
    }
958719
function validateObjectAttributeHTTPInput( $http, $base, $contentObjectAttribute )
    {
        if ( $http->hasPostVariable( $base . "_ezurl_url_" . $contentObjectAttribute->attribute( "id" ) )  and
             $http->hasPostVariable( $base . "_ezurl_text_" . $contentObjectAttribute->attribute( "id" ) )
           )
        {
            $url = $http->PostVariable( $base . "_ezurl_url_" . $contentObjectAttribute->attribute( "id" ) );
            $text = $http->PostVariable( $base . "_ezurl_text_" . $contentObjectAttribute->attribute( "id" ) );
            if ( $contentObjectAttribute->validateIsRequired() )
                if ( $url == "" )
                {
                    $contentObjectAttribute->setValidationError( ezpI18n::tr( 'kernel/classes/datatypes',
                                                                         'Input required.' ) );
                    return eZInputValidator::STATE_INVALID;
                }
            // Remove all url-object links to this attribute.
            eZURLObjectLink::removeURLlinkList( $contentObjectAttribute->attribute( "id" ), $contentObjectAttribute->attribute('version') );
        }
        else if ( $contentObjectAttribute->validateIsRequired() )
        {
            $contentObjectAttribute->setValidationError( ezpI18n::tr( 'kernel/classes/datatypes', 'Input required.' ) );
            return eZInputValidator::STATE_INVALID;
        }
        return eZInputValidator::STATE_ACCEPTED;
    }