Check the submitted base URL
515477
private function check_base_url()
    {
        $url_valid = filter_var($this->baseurl, FILTER_VALIDATE_URL);
        if (!$url_valid) {
            trigger_error('The URL provided is incomplete or invalid!');

            return false;
        }

        $base_url_components = parse_url($this->baseurl);
        if (empty($base_url_components['port'])) {
            trigger_error('The URL provided does not have a port suffix, normally this is :8443');

            return false;
        }

        return true;
    }
185995
def get_services_url(url, base_url):
        
        length = len(base_url)
        checks = ['http://', 'https://']
        for check in checks:
            if url.startswith(check):
                length = length + len(check)
                break

        result = url[length:]
        logger.debug('{0} from {1} equals {2}'
                     .format(base_url, url, result))
        return result
52020
def check_urls(urls):
    '''
    
    '''
    threads = list()
    progress_bar = None
    progress_counter = 0

    if SHOW_PROGRESS_BAR and len(urls) > 0:

        widgets = [SimpleProgress()]
        progress_bar = ProgressBar(widgets=widgets, maxval=len(urls)).start()

    for u in urls:
        t = Thread(target=async_check_url, args=(u[0], u[1], u[2]))
        t.start()
        threads.append(t)

    for thread in threads:
        if SHOW_PROGRESS_BAR and len(urls) > 0:
            progress_counter = progress_counter + 1
            progress_bar.update(progress_counter)

        thread.join()

    if SHOW_PROGRESS_BAR and len(urls) > 0:
        progress_bar.finish()
1209626
function checkUrl(link, baseUrl, cache, options, retry)
{
	var cached;
	
	if (retry === undefined)
	{
		if (isString(link) === true)
		{
			link = linkObj(link);
			linkObj.resolve(link, baseUrl, options);
		}
		
		// TODO :: move out to an `linkObj.invalidate()` to share with `HtmlChecker()` ?
		if (link.url.resolved === null)
		{
			link.broken = true;
			link.brokenReason = "BLC_INVALID";
			linkObj.clean(link);
			return Promise.resolve(link);
		}
		
		cached = cache.get(link.url.parsed);
		
		if (cached !== undefined)
		{
			return Promise.resolve(cached).then( function(response)
			{
				// Cloned to avoid unexpected mutations as a result of user changes
				response = extend({}, response);
				
				copyResponseData(response, link, options);
				
				link.http.cached = true;
				
				return link;
			});
		}
	}
	
	var request = bhttp.request(link.url.resolved,  // TODO :: https://github.com/joepie91/node-bhttp/issues/3
	{
		discardResponse: true,
		headers: { "user-agent":options.userAgent },
		method: retry!==405 ? options.requestMethod : "get"
	})
	.then( function(response)
	{
		response = simpleResponse(response);
		
		if (response.statusCode===405 && options.requestMethod==="head" && options.retry405Head===true && retry!==405)
		{
			// Retry possibly broken server with "get"
			return checkUrl(link, baseUrl, cache, options, 405);
		}
		
		// TODO :: store ALL redirected urls in cache
		if (options.cacheResponses===true && response.url!==link.url.resolved)
		{
			cache.set(response.url, response);  // TODO :: store `request` instead to be consistent?
		}
		
		return response;
	})
	.catch( function(error)
	{
		// The error will be stored as a response
		return error;
	});
	
	if (retry === undefined)
	{
		// Send response to cache -- it will be available to `cache.get()` before being resolved
		if (options.cacheResponses === true)
		{
			cache.set(link.url.parsed, request);
		}
		
		// Send linkObj to caller
		return request.then( function(response)
		{
			copyResponseData(response, link, options);
			
			link.http.cached = false;
			
			return link;
		});
	}
	else
	{
		return request;
	}
}
928223
def __pre_check(self, requestedUrl):
		'''
		
		'''
		components = urllib.parse.urlsplit(requestedUrl)

		netloc_l = components.netloc.lower()
		if netloc_l in Domain_Constants.SUCURI_GARBAGE_SITE_NETLOCS:
			self.__check_suc_cookie(components)
		elif netloc_l in Domain_Constants.CF_GARBAGE_SITE_NETLOCS:
			self.__check_cf_cookie(components)
		elif components.path == '/sucuri_shit_2':
			self.__check_suc_cookie(components)
		elif components.path == '/sucuri_shit_3':
			self.__check_suc_cookie(components)
		elif components.path == '/cloudflare_under_attack_shit_2':
			self.__check_cf_cookie(components)
		elif components.path == '/cloudflare_under_attack_shit_3':
			self.__check_cf_cookie(components)
560588
private FastRequestHandler verifyBase(URL baseUrl, String baseSupplied) {
        if (null == baseUrl) {
            if ("META-INF/resources/webjars".equalsIgnoreCase(baseSupplied)) {
                // webjars not provided, just ignore it.
            } else {
                logger.warn("URL base not exists: " + baseSupplied);
            }
            return AlwaysNotFound.INSTANCE;
        }
        return null;
    }
229978
def site_url(url):
    
    base_url = 'http://%s' % socket.gethostname()

    if server.port is not 80:
        base_url += ':%d' % server.port

    return urlparse.urljoin(base_url, url)
955685
function getBase (request, extra) {
  var parts = request.originalUrl.split('/');
  // Remove extra path parts.
  parts.splice(-extra, extra);
  return request.protocol + '://' + request.headers.host + parts.join('/');
}
979904
function RequestBase () {
    // `_baseUrl` and `self` are private variables
    var _baseUrl,
        self = this;

    this.getBaseUrl = function () {
      if (_baseUrl) {
        return _baseUrl;
      }
    };

    this.setBaseUrl = function (baseUrl) {
      _baseUrl = baseUrl;
    };

    /**
     * Checks to make sure the request was a success
     * @param  {Object}  res   A response object
     * @return {Boolean}       A boolean denoting whether the request was a success
     */
    this.isSuccess = function (res) {
      var success = function (status) {
        return status >= 200 && status < 300;
      };
      if (res && success(res.statusCode)) {
        return true;
      }
      return false;
    };

    this.buildOptions = function (path, method, payload) {
      var options,
          accessToken = this.getAccessToken(),
          relayIdentifier = this.getRelayIdentifier(),
          baseUrl = self.getBaseUrl(),
          url = self.constructUrl(baseUrl, path);

      options = {
        uri: url,
        method: method,
        headers: {}
      };

      if (accessToken) {
        options.headers.Authorization = 'Access-Token ' + accessToken;
      } else {
        throw new Error('The required Access Token is missing or malformed');
      }

      if (relayIdentifier) {
        options.headers['Relay-Identifier'] = relayIdentifier;
      }

      if (method && method.toUpperCase() === 'GET') {
        options.qs = payload;
      } else {
        options.json = payload;
      }
      return options;
    };

    this.constructUrl = function (url, path) {
      if (url.slice(-1) === '/' && path.slice(0, 1) === '/') {
        return url.slice(0, -1) + path;
      } else if (url.slice(-1) !== '/' && path.slice(0, 1) !== '/') {
        return url + '/' + path;
      }
      return url + path;
    };

    this.sendRequest = function (path, method, payload) {
      var options = self.buildOptions(path, method, payload),
          reqHandle = request(options).spread(function (response, body) {
            var resp = {},
                responseBody;
            try {
              if (typeof body === 'string') {
                responseBody = JSON.parse(body);
              } else {
                responseBody = body;
              }
            } catch (err) {
              throw new Error('An error occurred parsing the following response from the server: ' + body);
            }
            resp.body = responseBody;
            if (self.isSuccess(response)) {
              resp.getData = function () {
                return resp.body.data;
              };
              resp.isEmpty = function () {
                return Object.getOwnPropertyNames(resp.getData()).length === 0;
              };
              resp.getDataLength = function () {
                var data = resp.getData();
                if (resp.isEmpty()) {
                  return 0;
                } else if (!(data instanceof Array)) {
                  return 1;
                } else {
                  return data.length;
                }
              };
              if (method === 'GET' && resp.body.paging) {
                var pageSize, thisPage, prevPage, nextPage, pageFunc;
                pageSize = resp.body.paging['per_page'];
                thisPage = resp.body.paging.page;
                prevPage = (thisPage === 1 ? thisPage : thisPage - 1);
                nextPage = thisPage + 1;
                pageFunc = function (pageNum) {
                  var _pageNum;
                  _pageNum = pageNum;
                  return function () {
                    payload = (payload === undefined || !payload) ? {} : payload;
                    payload.page = _pageNum;
                    payload['per_page'] = pageSize;
                    return self.sendRequest(path, method, payload);
                  };
                };
                resp.nextPage = pageFunc(nextPage);
                resp.prevPage = pageFunc(prevPage);
              }
              return resp;
            } else {
              throw new error.ApiError(resp);
            }
          });
      return reqHandle;
    };
  }
1268751
def _get_fix_my_django_submission_url(self, tb_info, sanitized_tb):
        
        err_post_create_path = '/create/'
        url = '{0}{1}'.format(base_url, err_post_create_path)
        return '{url}?{query}'.format(
            url=url,
            query=urlencode({
                'exception_type': clean_exception_type(tb_info['parsed_traceback']['exc_type']),
                'error_message': tb_info['parsed_traceback']['exc_msg'],
                'django_version': '{0[0]}.{0[1]}'.format(django.VERSION),
                'traceback': sanitized_tb
            }))
1215956
function(url) {

        // Note: this is rudamentary.. not sure yet if it handles every case.
        if (/^https?:\/\//i.test(url)) {
            // absolute
            return url;
        }

        var baseParts = this.parseUrl(this.baseUrl);
        if (url.charAt('/')) {
            // Url starts with a slash
            return baseParts.root + url;
        }

        // Url does not start with a slash, we need grab the base url right up until the last slash.
        var newUrl = baseParts.root + '/';
        if (baseParts.path.lastIndexOf('/')!==-1) {
            newUrl = newUrl = baseParts.path.subString(0, baseParts.path.lastIndexOf('/')) + '/';
        }
        newUrl+=url;
        return url;

    }
1177382
public function submitUrl()
    {
        $aParams = \OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter("aSubmitUrl");
        if ($aParams['url']) {
            $sNotificationUrl = "http://gr-notify.appspot.com/submit?uri=" . urlencode($aParams['url']) . "&agent=oxid";
            if ($aParams['email']) {
                $sNotificationUrl .= "&contact=" . urlencode($aParams['email']);
            }
            $aHeaders = $this->getHttpResponseCode($sNotificationUrl);
            if (substr($aHeaders[2], -4) === "True") {
                $this->_aViewData["submitMessage"] = 'SHOP_RDFA_SUBMITED_SUCCESSFULLY';
            } else {
                \OxidEsales\Eshop\Core\Registry::getUtilsView()->addErrorToDisplay(substr($aHeaders[3], strpos($aHeaders[3], ":") + 2));
            }
        } else {
            \OxidEsales\Eshop\Core\Registry::getUtilsView()->addErrorToDisplay('SHOP_RDFA_MESSAGE_NOURL');
        }
    }
148819
def _is_valid_url(self, url):
        """"""
        try:
            r = requests.head(url, proxies=self.proxy_servers)
            value = r.status_code in [200]
        except Exception as error:
            logger.error(str(error))
            value = False

        return value
860427
def base_url(self, value):
        """"""
        logger.debug('StackInABox({0}): Updating URL from {1} to {2}'
                     .format(self.__id, self.__base_url, value))
        self.__base_url = value
        for k, v in six.iteritems(self.services):
            matcher, service = v
            service.base_url = StackInABox.__get_service_url(value,
                                                             service.name)
            logger.debug('StackInABox({0}): Service {1} has url {2}'
                         .format(self.__id, service.name, service.base_url))
640084
function resolveUrl(base, url) {
  var value = '';
  if (url.indexOf('://') != -1) {
    // Likely absolute...
    value = url;
  } else {
    // Combine by smashing together and letting the browser figure it out.
    if (url.length && url[0] == '/') {
      // URL is absolute, so strip base to just host.
      var i = url.indexOf('://') + 3;
      i = url.indexOf('/', i);
      if (i != -1) {
        value = base + url;
      } else {
        value = base.substr(0, i) + url;
      }
    } else {
      // URL is relative, so combine with base.
      if (base[base.length] == '/') {
        value = base + '/' + url;
      } else {
        value = base + '/../' + url;
      }
    }
  }
  return value;
}
693553
def _validateurl(self, url):
        """"""
        parsed = urlparse(url)
        path = parsed.path.strip("/")
        if path:
            parts = path.split("/")
            url_types = ("admin", "manager", "rest")
            if any(i in parts for i in url_types):
                while parts.pop() not in url_types:
                    next
            elif "services" in parts:
                while parts.pop() not in "services":
                    next
            path = "/".join(parts)
        else:
            path = "arcgis"
        self._adminUrl = "%s://%s/%s/admin" % (parsed.scheme, parsed.netloc, path)
        return "%s://%s/%s/rest/services" % (parsed.scheme, parsed.netloc, path)
800217
protected function _getBaseUrl() {
		do {
			$baseUrl = $this->in(__d('cake_installer', 'Input base URL (e.g. %s):', 'http://someapp.fabrikam.com'));
			$baseUrl = trim($baseUrl);
		} while (!preg_match('/http[s]?\:\/\/[A-z0-9\.\/]+/', $baseUrl));

		return trim($baseUrl, '/');
	}