Get the base URL for the request.

@param  string $scheme
@param  string $root
@return string
430916
protected function getRootUrl( $scheme, $root = null )
	{
		if ( is_null( $root ) )
		{
			if ( is_null( $this->cachedRoot ) )
			{
				$this->cachedRoot = $this->forcedRoot ?: $this->request->root();
			}

			$root = $this->cachedRoot;
		}

		$start = Str::startsWith( $root, 'http://' ) ? 'http://' : 'https://';

		return preg_replace( '~' . $start . '~', $scheme, $root, 1 );
	}
590957
public function getApiUrl($scheme = true)
    {
        return Url::toRoute([
            '/wechat/' . Yii::$app->getModule('wechat')->apiRoute,
            'id' => $this->id
        ], $scheme);
    }
103998
def base_url(root):
    """"""
    for attr, value in root.attrib.iteritems():
        if attr.endswith('base') and 'http' in value:
            return value
    return None
943003
public function getBaseUri()
    {
        if ('' !== $qs = $this->getQueryString()) {
            $qs = '?' . $qs;
        }

        return $this->getSchemeAndHost() . $this->getRequestUri() . $qs;
    }
858819
public function get($args = [], $scheme = false)
    {
        if (is_string($args)) {
            $url = $args;
            if ($url === '') {
                return $this->router->createUrl($url, $scheme);
            } elseif ($url[0] === '/') {
                $url = $this->alias->get('@web') . $url;
                if (!$scheme) {
                    return $url;
                }
            } elseif (parse_url($url, PHP_URL_SCHEME)) {
                return $url;
            } else {
                return $this->router->createUrl($url, $scheme);
            }
            $anchor = null;
            $args = '';
        } else {
            $url = $args[0];
            if ($url === '') {
                return $this->router->createUrl($args, $scheme);
            } elseif ($url[0] === '/') {
                $url = $this->alias->get('@web') . $url;
            } elseif (parse_url($url, PHP_URL_SCHEME)) {
                null;
            } else {
                return $this->router->createUrl($args, $scheme);
            }

            $anchor = isset($args['#']) ? $args['#'] : null;
            unset($args[0], $args['#']);
        }

        if ($args) {
            $url .= (strpos($url, '?') !== false ? '&' : '?') . http_build_query($args);
        }

        if ($anchor !== null) {
            $url .= '#' . $anchor;
        }

        if ($scheme) {
            if ($scheme === true) {
                $scheme = $this->request->getScheme();
            }
            return ($scheme === '//' ? $scheme : "$scheme://") . $this->request->getServer('HTTP_HOST') . $url;
        } else {
            return $url;
        }
    }
435616
public function setScheme(string $scheme) : Request
    {
        $scheme = strtolower($scheme);

        if ($scheme === 'http') {
            $this->isSecure = false;
        } elseif ($scheme === 'https') {
            $this->isSecure = true;
        } else {
            throw new \InvalidArgumentException('The scheme must be http or https.');
        }

        return $this;
    }
1271007
public function getHostBaseUrl($host = null)
    {
        $config = $this->getFullHost($host);

        return sprintf('%s://%s', $config['protocol'], $config['host']);
    }
857288
public function setScheme( ?string $scheme = null ) : Url
   {

      if ( null === $scheme || ! \preg_match( '~^[a-z]{3,7}$~i', $scheme ) )
      {
         $this->scheme = 'http';
         return $this;
      }

      $this->scheme = $scheme;

      return $this;

   }
1058833
public function baseUrl($uri = '')
    {
        return sprintf(
            "%s://%s%s%s%s",
            isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off' ? 'https' : 'http',
            $_SERVER['SERVER_NAME'],
            ($_SERVER['SERVER_PORT'] == 80) ?: ':' . $_SERVER['SERVER_PORT'],
            $_SERVER['REQUEST_URI'],
            ltrim($uri, '/')
        );
    }
858641
protected function getBaseUrl()
    {
        $port = '';
        if ($this->requestContext->getScheme() === 'https' && $this->requestContext->getHttpsPort() != 443) {
            $port = ":{$this->requestContext->getHttpsPort()}";
        }

        if ($this->requestContext->getScheme() === 'http' && $this->requestContext->getHttpPort() != 80) {
            $port = ":{$this->requestContext->getHttpPort()}";
        }

        $baseUrl = $this->requestContext->getBaseUrl();
        if (substr($this->requestContext->getBaseUrl(), -4) === '.php') {
            $baseUrl = pathinfo($this->requestContext->getBaseurl(), PATHINFO_DIRNAME);
        }
        $baseUrl = rtrim($baseUrl, '/\\');

        return sprintf(
            '%s://%s%s%s',
            $this->requestContext->getScheme(),
            $this->requestContext->getHost(),
            $port,
            $baseUrl
        );
    }
1031762
protected function getAssetBaseUrl()
    {
        $baseUrl = $this->hasOption(self::BASE_OPTION_KEY) ? $this->getOption(self::BASE_OPTION_KEY) : ROOT_URL;

        $baseUrl = trim($baseUrl);
        if(substr($baseUrl, -1) != '/'){
            $baseUrl .= '/';
        }

        return $baseUrl;
    }
548926
public function getPaths($scheme = null)
    {
        return !$scheme ? $this->schemes : (isset($this->schemes[$scheme]) ? $this->schemes[$scheme] : []);
    }
659792
protected function filterScheme($scheme): string
    {
        if (!\is_string($scheme) && !\method_exists($scheme, '__toString')) {
            throw new \InvalidArgumentException('Uri scheme must be a string');
        }

        $scheme = \str_replace('://', '', \strtolower((string)$scheme));
        if (!isset(static::$validScheme[$scheme])) {
            throw new \InvalidArgumentException('Uri scheme must be one of: "", "https", "http"');
        }

        return $scheme;
    }
417282
protected function filterScheme(string $scheme = null): string
    {
        if (null === $scheme) {
            return '';
        }

        $scheme = strtolower($scheme);
        $scheme = rtrim($scheme, ':/');

        return $scheme;
    }
590673
protected static function _createUriString($scheme, $authority, $path, $query, $fragment)
    {
        $uri = '';

        if (! empty($scheme)) {
            $uri .= sprintf('%s://', $scheme);
        }

        if (! empty($authority)) {
            $uri .= $authority;
        }

        if ($path) {
            if (empty($path) || '/' !== substr($path, 0, 1)) {
                $path = '/' . $path;
            }

            $uri .= $path;
        }

        if ($query) {
            $uri .= sprintf('?%s', $query);
        }

        if ($fragment) {
            $uri .= sprintf('#%s', $fragment);
        }

        return $uri;
    }
712860
static public function getBaseUrl($uri='')
	{
		$baseUrl  = static::getRootUrl();
		$baseUrl .= isset($_SERVER['SCRIPT_NAME']) ? dirname($_SERVER['SCRIPT_NAME']) : dirname(getenv('SCRIPT_NAME'));
		
		return rtrim(str_replace('\\', '/', $baseUrl), '/');
	}
1270137
private function normalizeScheme($scheme)
    {
        if (!is_string($scheme) && !method_exists($scheme, '__toString')) {
            throw new InvalidArgumentException('Uri scheme must be a string');
        }

        $scheme = str_replace('://', '', strtolower((string) $scheme));
        if (!isset($this->validSchema[$scheme])) {
            throw new InvalidArgumentException('Uri scheme must be one of: "", "https", "http"');
        }

        return $scheme;
    }