Validates the URL
    :param url:
    :return:
3381
def validate_url(url):
    
    if validators.url(url):
        return url
    elif validators.domain(url):
        return "http://{}".format(url)
    return ""
31157
protected function validateUrl()
    {
        $this->url->convertToHttps();
        return ($this->urlMatchesPattern(array_merge($this->postPatterns, $this->videoPatterns, $this->pagePatterns)));
    }
1087474
def validate(self, uri):
		
		if WURIComponentVerifier.validate(self, uri) is False:
			return False
		try:
			WStrictURIQuery(
				WURIQuery.parse(uri.component(self.component())),
				*self.__specs,
				extra_parameters=self.__extra_parameters
			)
		except ValueError:
			return False
		return True
453352
def is_valid_url(url):
    
    regex = 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 bool(regex.match(url))
1183377
def is_valid_url(self, url, non_blocking=True):
        """"""
        logger.debug(str((url)))
        if non_blocking:
            method = self._is_valid_url
            return self._create_worker(method, url)
        else:
            return self._is_valid_url(url)
185018
protected function validateUrl()
    {
        $this->url->convertToHttp();
        $this->url->stripWWW();

        return (preg_match('~polldaddy\.com/(?:poll|s|ratings)/(?:[^/]+)/?$~i', $this->url));
    }
723632
def _is_valid_url(url):
        
        try:
            parsed = urlparse(url)
            mandatory_parts = [parsed.scheme, parsed.netloc]
            return all(mandatory_parts)
        except:
            return False
27474
def validate_urls(urls, allowed_response_codes=None):
    

    for url in urls:
        validate_url(url, allowed_response_codes=allowed_response_codes)
    return True
407389
def validate(self, input_string):
        
        parsed_url = urlparse(url=input_string)
        return bool(parsed_url.scheme and parsed_url.netloc)
344639
function(url, cb) {
        var calais = this;

        if (!calais.validateOptions())
            return cb({}, 'Bad options');

        //Make sure we were given a URL.
        if (this._undefinedOrNull(url) || typeof url != 'string' || url.length == 0)
            return cb({}, 'No URL given.');

        //Make sure it's a valid URL.
        if (!(/^(https?|ftp):\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i.test(url)))
            return cb({}, 'Bad URL');


        request(url, function(error, response, html) {
            if (error)
                return cb({}, error);

            //Limts to just under 100kb....
            html = html.substring(0, 95000);
            
            //We can upload the html directly to Calais if we set the contentType as text/html
            var params = {
                'Host'                   : calais.options.apiHost,
                'x-ag-access-token'      : calais.apiKey,
                'x-calais-language'      : calais.options.language,
                'Content-Type'           : 'text/html',
                'Accept'                 : 'application/json',
                'Content-Length'         : html.length,
                'OutputFormat'           : 'application/json'
            };

            var options = {
                uri    : 'https://' + calais.options.apiHost + calais.options.apiPath,
                method : 'POST',
                body   : html,
                headers: params
            };


            request(options, function(error, response, calaisData) {

                if (error)
                    return cb({}, error);

                if (response === undefined) {
                    return cb({}, 'Undefined Calais response');
                } else if (response.statusCode === 200) {
                    if (!calaisData)
                        return cb({}, calais.errors);

                    try {
                        // parse to a Javascript object if requested
                        var result = JSON.parse(calaisData);
                        result = (typeof result === 'string') ? JSON.parse(result) : result;

                        var parsedResult;
                        if (calais.options.parseData) {
                            parsedResult = calais._parseCalaisData(result, calais.options.minConfidence);
                        } else {
                            parsedResult = result;
                        }

                        return cb(parsedResult, calais.errors);
                    } catch(e) {
                        return cb({}, e);
                    }

                } else
                    return cb({}, 'Request error: ' + (typeof response === 'string' ? response : JSON.stringify(response)));


            });

        });

    }
1634
def match(self, url: str) -> RouteResolved:
        
        url = normalize_url(url)
        parts = self._deconstruct_url(url)
        return self._match(parts)
1244096
function validateUrl(url) {
        var validate = appOptions.validate,
            type = Object.prototype.toString.call(validate);

        if (type === "[object RegExp]") {
            return validate.test(url);
        } else if (type === "[object Function]") {
            return validate(url);
        } else {
            return true;
        }
    }
641124
def validate_extension(url_hash, url)
      return unless url.present?
      uri_parts = URI(url).host&.split('.')
      url_exts = uri_parts[2..-1]

      ### Finds Errors
      if url_exts.empty? ## Missing ext.
        err_msg = 'error: ext.none'
      else ## Has ext(s), but need to verify validity and count.
        iana_list = CrmFormatter::Extensions.list
        matched_exts = iana_list & url_exts

        if matched_exts.empty? ## Has ext, but not valid.
          err_msg = "error: ext.invalid [#{url_exts.join(', ')}]"
        elsif matched_exts.count > 1 ## Has too many valid exts, Limit 1.
          err_msg = "error: ext.valid > 1 [#{matched_exts.join(', ')}]"
        end
      end

      if err_msg
        url_hash[:web_neg] << err_msg
        url = nil
        url_hash[:url_f] = nil
        return { url_hash: url_hash, url: url }
      end

      ### Only Non-Errors Get Here ###
      ## Has one valid ext, but need to check if original url exts were > 1.  Replace if so.
      if url_exts.count > matched_exts.count
        matched_ext = matched_exts.first
        u1 = url.split(matched_ext).first
        url = "#{u1}#{matched_ext}"
        # inv_ext = (url_exts - matched_exts).join
        # url = url.gsub(".#{inv_ext}", '')
      end

      ext_result = { url_hash: url_hash, url: url }
      ext_result
    end
420318
def check(self, url: str) -> Optional[dict]:
        
        data = self.data.get(url)
        if data:
            data = self._check_expiration(url, data)
        return data.data if data else None
200458
public function validateUrl($url)
    {
        if (empty($url)) {
            throw new \InvalidArgumentException('The field cannot be empty.');
        }

        if (!filter_var($url, FILTER_VALIDATE_URL)) {
            throw new \InvalidArgumentException('The field requires a valid URL.');
        }

        return $url;
    }
998341
def is_valid_url(url):
    """"""
    pieces = urlparse(url)
    return all([pieces.scheme, pieces.netloc])
1091235
def accepts_valid_urls(func):
    
    @functools.wraps(func)
    def wrapper(obj, urls, *args, **kwargs):
        """Run the function and return a value for valid URLs.

        :param obj: an object in whose class f is defined
        :param urls: an iterable containing URLs
        :returns: a return value of the function f
        :raises InvalidURLError: if the iterable contains invalid URLs
        """
        invalid_urls = [u for u in urls if not is_valid_url(u)]
        if invalid_urls:
            msg_tpl = 'The values: {} are not valid URLs'
            msg = msg_tpl.format(','.join(invalid_urls))
            raise InvalidURLError(msg)
        return func(obj, urls, *args, **kwargs)
    return wrapper