Validates URL
@param {Object} url
@param {String} hostname
@param {String} service
@param {String} owner
@param {String} repo
187220
function validateUrl(url, hostname, service, owner, repo) {
    // validate if given url is a valid url
  if (url.hostname !== hostname || !owner || !repo) {
    const errorMessage = `The URL must be a valid ${
        service
      } URL in the following format: https://${
        hostname
      }/serverless/serverless`;
    throw new ServerlessError(errorMessage);
  }
}
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
138529
@Override
    public void validate(String host, int port, String path, boolean secure, Cookie cookie) throws MalformedCookieException {
        LOG.trace("enter CookieSpecBase.validate("
            + "String, port, path, boolean, Cookie)");
        if (host == null) {
            throw new IllegalArgumentException(
                "Host of origin may not be null");
        }
        if (host.trim().equals("")) {
            throw new IllegalArgumentException(
                "Host of origin may not be blank");
        }
        if (port < 0) {
            throw new IllegalArgumentException("Invalid port: " + port);
        }
        if (path == null) {
            throw new IllegalArgumentException(
                "Path of origin may not be null.");
        }
        host = host.toLowerCase();
        // check version
        if (cookie.getVersion() < 0) {
            throw new MalformedCookieException ("Illegal version number " 
                + cookie.getValue());
        }

        // security check... we musn't allow the server to give us an
        // invalid domain scope

        // Validate the cookies domain attribute.  NOTE:  Domains without 
        // any dots are allowed to support hosts on private LANs that don't 
        // have DNS names.  Since they have no dots, to domain-match the 
        // request-host and domain must be identical for the cookie to sent 
        // back to the origin-server.
        if (host.indexOf(".") >= 0) {
            // Not required to have at least two dots.  RFC 2965.
            // A Set-Cookie2 with Domain=ajax.com will be accepted.

            // domain must match host
            if (!host.endsWith(cookie.getDomain())) {
                String s = cookie.getDomain();
                if (s.startsWith(".")) {
                    s = s.substring(1, s.length());
                }
                if (!host.equals(s)) { 
                    throw new MalformedCookieException(
                        "Illegal domain attribute \"" + cookie.getDomain() 
                        + "\". Domain of origin: \"" + host + "\"");
                }
            }
        } else {
            if (!host.equals(cookie.getDomain())) {
                throw new MalformedCookieException(
                    "Illegal domain attribute \"" + cookie.getDomain() 
                    + "\". Domain of origin: \"" + host + "\"");
            }
        }
    }
1077393
def filter_service_by_regex_host_name(regex):
    
    host_re = re.compile(regex)

    def inner_filter(items):
        """Inner filter for service. Accept if regex match service.host.host_name"""
        service = items["service"]
        host = items["hosts"][service.host]
        if service is None or host is None:
            return False
        return host_re.match(host.host_name) is not None

    return inner_filter
970078
function checkHost(host,callback) {

	if(hostCache.get(host,callback)) {
		console.log('checkHost: Resolved %s from hostCache...',host);
		return true;
	}

	console.log('checkHost: Looking up %s...',host);

	var options = {
		host: host,
		port: 80,
		path: '/',
		method: 'GET'
	};

	var req = http.request(options, function(res) {
		var data = '';
		res.setEncoding('utf8');

		res.on('data', function (chunk) {
			data += chunk;
		});
		res.on('end', function () {
			hostCache.set(host,true);
		});
		res.on('error',function() {
			hostCache.set(host,false);
		});
	});
	req.on('error',function() {
		hostCache.set(host,false);
	});
	req.end();
}
1191732
def surl(service)
      service_url = @env == :stable ? API_URL : SANDBOX_API_URL
      service_url = service_url + "/" + service
      service_url.gsub!('www', 'usercontent') if service.to_s == 'image'
      service_url
    end
27474
def validate_urls(urls, allowed_response_codes=None):
    

    for url in urls:
        validate_url(url, allowed_response_codes=allowed_response_codes)
    return True
1248061
function parseGithubURL(url) {
  var githubUrlRe = /github\.com\/([^/]+)\/([^/]+)\/pull\/([0-9]+)/;
  var match = url.match(githubUrlRe);

  if (!match) {
    return null;
  }

  return {
    owner: match[1],
    repo: match[2],
    number: match[3]
  };
}
955243
function s(originalUrl) {
  var parts = new url.URL(originalUrl);
  return url.format(parts, { auth: false });
}
911993
public static boolean validateUrl(String url) {
        String[] schemes = {"https"};
        UrlValidator urlValidator = new UrlValidator(schemes);
        return urlValidator.isValid(url);
    }
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
969041
function getHostname(url, userOptions = {}) {
  const defaults = {
    removeSubdomains: true,
  };
  const options = Object.assign({}, defaults, userOptions);
  const domainRegExp = /^(?:[a-z]+:\/\/)?(?:[^/@]+@)?([^/:]+)/i;
  const ipAddressRegExp = /^\d{1,3}\.\d{1,3}.\d{1,3}\.\d{1,3}$/;
  const domainMatch = url.match(domainRegExp);

  if (domainMatch === null) {
    throw new Error(`URL is invalid: ${url}`);
  }

  // If the hostname is an IP address, no further processing can be done.
  const hostname = domainMatch[1];
  if (ipAddressRegExp.test(hostname)) {
    return hostname;
  }

  // Return the hostname with subdomains removed, if requested.
  return (options.removeSubdomains) ? removeSubdomains(hostname) : hostname;
}
659308
def _validate_response(url, response):
    """"""
    if response['status'] not in [GooglePlaces.RESPONSE_STATUS_OK,
                                  GooglePlaces.RESPONSE_STATUS_ZERO_RESULTS]:
        error_detail = ('Request to URL %s failed with response code: %s' %
                        (url, response['status']))
        raise GooglePlacesError(error_detail)
670960
function parseUrl (url) {
  var urlRegExp = /(git:\/\/)|(http:\/\/)/;

  if(urlRegExp.test(url)) {
    return url.replace(urlRegExp, 'https://');
  }

  return url;
}
270504
def validate_owner_repo_distro(ctx, param, value):
    """"""
    # pylint: disable=unused-argument
    form = "OWNER/REPO/DISTRO[/RELEASE]"
    return validate_slashes(param, value, minimum=3, maximum=4, form=form)
346048
function (resource) {
                    validate(resource);
                    var rel = Object.keys(resource)[0];
                    home[endpoint] = home[endpoint] ? home[endpoint] : {};
                    home[endpoint][rel] = resource[rel];
                }
1145007
def validate_repo_url(url):
    
    try:
        if "github.com" in url:
            return re.findall(r"https?://w?w?w?.?github.com/[\w\-]+/[\w.-]+", url)[0]
        elif "bitbucket.org" in url:
            return re.findall(r"https?://bitbucket.org/[\w.-]+/[\w.-]+", url)[0] + "/src/"
        elif "launchpad.net" in url:
            return re.findall(r"https?://launchpad.net/[\w.-]+", url)[0]
        elif "sourceforge.net" in url:
            mo = re.match(r"https?://sourceforge.net/projects/"
                          r"([\w.-]+)/", url, re.I)
            template = "https://sourceforge.net/p/{}/code/HEAD/tree/trunk/src/"
            return template.format(mo.groups()[0])
    except (IndexError, AttributeError):
        pass
    return ""