Add 'http://' to a link, if it has no protocol already.

@param string $url
@param string $scheme

@return string
186015
public static function addScheme($url, $scheme = 'http://')
    {
        $url = parse_url($url, PHP_URL_SCHEME) === null ? $scheme . $url : $url;

        return $url;
    }
452087
public function withScheme($scheme): UriInterface
    {
        $scheme = $this->filterScheme($scheme);

        $clone = clone $this;
        $clone->scheme = $scheme;

        return $clone;
    }
1093294
protected function convertUrl($url, $https)
    {
        $scheme = ($https) ? 'https' : 'http';
        $parser = new Url($url);
        $parser->setScheme($scheme);

        return $parser->__toString();
    }
36226
public function appendScheme(Scheme $scheme): self
    {
        return new self(
            (string) $this->pregReplace(
                '/^[a-zA-Z]*:?\/\//',
                (string) $scheme . '://'
            )
        );
    }
309794
private function getInvalidLinkError($scheme, $url)
    {
        switch ($scheme) {
            case 'ezcontent':
            case 'ezremote':
                return sprintf('Invalid link "%s": target content cannot be found', $url);
            case 'ezlocation':
                return sprintf('Invalid link "%s": target location cannot be found', $url);
            default:
                throw new InvalidArgumentException($scheme, "Given scheme '{$scheme}' is not supported.");
        }
    }
137087
public static function filterScheme($scheme)
    {
        $scheme = strtolower($scheme);
        $scheme = preg_replace('#:(//)?$#', '', $scheme);

        if (empty($scheme)) {
            return '';
        }

        return $scheme;
    }
1235542
private function admin_url( $path = '', $scheme = 'admin', $network = true ) {
            return ( $this->_is_network_active && $network ) ?
                network_admin_url( $path, $scheme ) :
                admin_url( $path, $scheme );
        }
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;
    }
299066
public static function getHome($path = '',$scheme = '')
	{
		$domain = Config::get('@.DOMAIN');
		if(empty($domain))
		{
			$domain = $_SERVER['HTTP_HOST'] . strtr(dirname($_SERVER['SCRIPT_NAME']), '\\','/');
		}
		if('' === $scheme)
		{
			$scheme = Config::get('@.URL_PROTOCOL');
			if(empty($scheme))
			{
				$scheme=Request::getProtocol();
			}
		}
		if((!isset($path[0]) || '/' !== $path[0]) && '/' !== substr($domain,-1,1))
		{
			$path = '/' . $path;
		}
		return $scheme . $domain . $path;
	}
1299023
def with_scheme(self, scheme):
        """"""
        # N.B. doesn't cleanup query/fragment
        if not isinstance(scheme, str):
            raise TypeError("Invalid scheme type")
        if not self.is_absolute():
            raise ValueError("scheme replacement is not allowed " "for relative URLs")
        return URL(self._val._replace(scheme=scheme.lower()), encoded=True)
245295
private function forceHTTPSScheme($url)
    {
        if(env('FORCE_HTTPS_SCHEME')) {
            $url->formatScheme('https');
            $this->app['request']->server->set('HTTPS', true);
        }
    }
417282
protected function filterScheme(string $scheme = null): string
    {
        if (null === $scheme) {
            return '';
        }

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

        return $scheme;
    }
202643
public function get($scheme = self::REL)
    {
        $data = $this->data;
        if ($scheme == self::REL) {
            unset($data['scheme'], $data['host'], $data['user'], $data['pass'], $data['port']);
            return $this->build($data);
        }
        if (!isset($data['host'])) {
            $data['host'] = $this->request->getHost();
        }
        if (!isset($data['scheme'])) {
            $scheme = self::SHORT_ABS;
        }

        if ($scheme == self::SHORT_ABS) {
            unset($data['scheme']);
            $url = $this->build($data, '//');
        } else {
            $url = $this->build($data);
        }

        return $this->asProtect($url, $data['host']);
    }
1206850
private static function createUriString(
        $scheme = null,
        $authority = null,
        $path = null,
        $query = null,
        $fragment = null
    ) {
        $uri = '';
        $hierPart = '';

        if ($scheme !== null) {
            $uri .= $scheme . ':';
        }

        if (!$authority !== '') {
            if ($scheme !== null && $scheme !== 'urn') {
                $hierPart .= '//';
            }
            $hierPart .= $authority;
        }

        if ($path !== null) {
            // Add a leading slash if necessary.
            if ($hierPart && strpos($path, '/') !== 0) {
                $hierPart .= '/';
            }
            $hierPart .= $path;
        }

        $uri .= $hierPart;

        // if query is present prepend ? sign
        if ($query !== null) {
            $uri .= '?' . $query;
        }

        // if fragment is present prepend # sign
        if ($fragment !== null) {
            $uri .= '#' . $fragment;
        }

        return $uri;
    }
523099
public function matchesScheme($scheme)
    {
        $scheme = strtolower($scheme);
        $secure = $this->_data['secure'];
        return ($secure && $scheme === 'https') || (!$secure && $scheme === 'http');
    }
917931
def with_default_scheme(url)
      parsed(url) && parsed(url).scheme.nil? ? 'http://' + url : url
    end
896110
public static function tryAddUrlScheme($url, $scheme = 'http')
    {
        $urlScheme = parse_url($url, PHP_URL_SCHEME);

        if (empty($urlScheme)) {
            $url = "$scheme://".$url;
        }

        return $url;
    }