Returns a new Url object from a native url string

@param $url_string
@return Url
160377
public static function fromNative()
    {
        $urlString = \func_get_arg(0);

        $user        = \parse_url($urlString, PHP_URL_USER);
        $pass        = \parse_url($urlString, PHP_URL_PASS);
        $host        = \parse_url($urlString, PHP_URL_HOST);
        $queryString = \parse_url($urlString, PHP_URL_QUERY);
        $fragmentId  = \parse_url($urlString, PHP_URL_FRAGMENT);
        $port        = \parse_url($urlString, PHP_URL_PORT);

        $scheme     = new SchemeName(\parse_url($urlString, PHP_URL_SCHEME));
        $user       = $user ? new StringLiteral($user) : new StringLiteral('');
        $pass       = $pass ? new StringLiteral($pass) : new StringLiteral('');
        $domain     = Domain::specifyType($host);
        $path       = new Path(\parse_url($urlString, PHP_URL_PATH));
        $portNumber = $port ? new PortNumber($port) : new NullPortNumber();
        $query      = $queryString ? new QueryString(\sprintf('?%s', $queryString)) : new NullQueryString();
        $fragment   = $fragmentId ? new FragmentIdentifier(\sprintf('#%s', $fragmentId)) : new NullFragmentIdentifier();

        return new self($scheme, $user, $pass, $domain, $portNumber, $path, $query, $fragment);
    }
737900
public static function str2url($str)
    {
        $str = self::rus2translit($str);
        $str = strtolower($str);
        $str = preg_replace('~[^-a-z0-9_]+~u', '-', $str);
        $str = trim($str, "-");
        return $str;
    }
261526
protected String getNextUrl() {
		String url = urls.get(currentIndex);
		currentIndex = (currentIndex + 1) % urls.size();
		return url;
	}
525169
def _get_url(url):
        
        if isinstance(url, urlparse.ParseResult):
            return urlparse.urlunparse(url)
        else:
            return url
23833
public static function preprocess($url_parsed) {
        $url = URL::build($url_parsed);
        if (preg_match('/^[\w\/]*\/index.html$/', $url_parsed['path']) == 1) {
            parse_str($url_parsed['query'], $args);
            if (isset($args['s']) && isset($args['i'])) {
                return array(
                    'url' => $url,
                );
            }
        }
        return FALSE;
    }
606634
public static function fromString(string $uriString)
    {
        if (strlen($uriString) === 0) {
            throw new MalformedUri('Empty string is not a valid URI');
        }

        $uri = new ConstructedUri(new ParsedUri($uriString));
        if ($uri->isSyntacticallyValid()) {
            return $uri;
        }

        throw new MalformedUri('The URI ' . $uriString . ' is not a valid URI.');
    }
1162102
public function absoluteUrlFilter($string)
    {
        $url    = $this->grav['uri']->base();
        $string = preg_replace('/((?:href|src) *= *[\'"](?!(http|ftp)))/i', "$1$url", $string);

        return $string;

    }
1211276
private function curlGet($curl_url)
    {
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $curl_url);
        curl_setopt($ch, CURLOPT_HTTPHEADER, [
          'Accept: application/json',
          'Content-Type: application/json',
        ]);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        $json_result = curl_exec($ch);
        $result = json_decode($json_result);
        $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
        curl_close($ch);

        if ($http_code != 200) {
            throw new Exception('curlGet responded with '.$http_code);
        }

        return $result;
    }
50227
public static function url()
    {
        if (! isset(self::$_url)) {
            $url = self::scheme().'://';

            if (PHP_SAPI !== 'cli') {
                /*
            	 * Since we are assigning the URI from the server variables, we first need
             	 * to determine if we are running on apache or IIS.  If PHP_SELF and REQUEST_URI
             	 * are present, we will assume we are running on apache.
             	 */
                if (! empty($_SERVER['PHP_SELF']) && !empty($_SERVER['REQUEST_URI'])) {
                    /*
                 	 * To build the entire URI we need to prepend the protocol, and the http host
                 	 * to the URI string.
                 	 */
                    $url .= $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];

                    /*
                 	 * Since we do not have REQUEST_URI to work with, we will assume we are
                 	 * running on IIS and will therefore need to work some magic with the SCRIPT_NAME and
                 	 * QUERY_STRING environment variables.
                 	 */
                } else {
                    // IIS uses the SCRIPT_NAME variable instead of a REQUEST_URI variable
                    $url .= $_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME'];

                    // If the query string exists append it to the URI string
                    if (isset($_SERVER['QUERY_STRING']) && !empty($_SERVER['QUERY_STRING'])) {
                        $url .= '?' . $_SERVER['QUERY_STRING'];
                    }
                }
            } else {
                $url .= 'anahita';
            }

            // Sanitize the url since we can't trust the server var
            $url = AnService::get('anahita:filter.url')->sanitize($url);

            // Create the URI object
            self::$_url = AnService::get('anahita:http.url', array('url' => $url));
        }

        return self::$_url;
    }
618379
static function fromString(string $string): self
    {
        $string = str_replace("/", "\\", $string);
        $string = preg_replace("#(\\\\){2,}#", "\\", $string);
        if (substr($string, -1, 1) == "\\") {
            $string = substr($string, 0, -1);
        }
        
        return new self($string);
    }
573474
private static function createOTP(array $parsed_url): OTPInterface
    {
        switch ($parsed_url['host']) {
            case 'totp':
                $totp = TOTP::create($parsed_url['query']['secret']);
                $totp->setLabel(self::getLabel($parsed_url['path']));

                return $totp;
            case 'hotp':
                $hotp = HOTP::create($parsed_url['query']['secret']);
                $hotp->setLabel(self::getLabel($parsed_url['path']));

                return $hotp;
            default:
                throw new \InvalidArgumentException(sprintf('Unsupported "%s" OTP type', $parsed_url['host']));
        }
    }
1205997
public static function fromString(string $string): self
    {
        try {
            $data = Uri\parse(trim($string));
        } catch (\Exception $e) {
            throw new InvalidArgumentException;
        }

        return new self(
            $data['scheme'] ? new Scheme($data['scheme']) : new NullScheme,
            new Authority(
                new UserInformation(
                    $data['user'] ? new User($data['user']) : new NullUser,
                    $data['pass'] ? new Password($data['pass']) : new NullPassword
                ),
                $data['host'] ? new Host($data['host']) : new NullHost,
                $data['port'] ? new Port((int) $data['port']) : new NullPort
            ),
            $data['path'] && !empty($data['path']) ? new Path($data['path']) : new NullPath,
            $data['query'] ? Query::fromString($data['query']) : new NullQuery,
            $data['fragment'] ? new Fragment($data['fragment']) : new NullFragment
        );
    }
611684
private function buildUrl($endpoint, $url_parameters = [], $special_url = null)
    {
        foreach ($url_parameters as $key => $value) {
            //@codeCoverageIgnoreStart
            $endpoint = str_replace('{'.$key.'}', $value, $endpoint);
            //@codeCoverageIgnoreEnd
        }

        if (is_null($special_url)) {
            $url = trim($this->api_base_url, "/ \t\n\r\0\x0B");
        } else {
            $url = $special_url;
        }
        $url = $url.'/'.trim($endpoint, "/ \t\n\r\0\x0B");

        return $url;
    }
942328
function urlFor($internalUri, $locale = NULL){
        $internalUri= ltrim($internalUri, '/');
        if($locale == NULL)return $this->request->realBaseUrl . $internalUri;
        else return $this->request->realBaseUrl . $locale . '/' . $internalUri;
    }
231722
def url_get_html(url_str)
      url = URI.parse(URI.encode(url_str)) # first get total size
      req = Net::HTTP::Get.new(url.to_s)
      res = Net::HTTP.start(url.host, url.port) { |http| http.request(req) }
      res.body
    end
187402
private static URL safeURL(String urlString) throws ClassNotFoundException
	{
		try
		{
			return new URL(urlString);
		}
		catch (MalformedURLException exception)
		{
			throw new ClassNotFoundException(exception.getMessage());
		}
	}
958273
public static function buildUrl($parsed_url)
    {
        $scheme    = isset($parsed_url['scheme']) ? $parsed_url['scheme'] . ':' : '';
        $authority = isset($parsed_url['host']) ? '//' : '';
        $host      = $parsed_url['host'] ?? '';
        $port      = isset($parsed_url['port']) ? ':' . $parsed_url['port'] : '';
        $user      = $parsed_url['user'] ?? '';
        $pass      = isset($parsed_url['pass']) ? ':' . $parsed_url['pass']  : '';
        $pass      = ($user || $pass) ? "{$pass}@" : '';
        $path      = $parsed_url['path'] ?? '';
        $path      = !empty($parsed_url['params']) ? rtrim($path, '/') . static::buildParams($parsed_url['params']) : $path;
        $query     = !empty($parsed_url['query']) ? '?' . $parsed_url['query'] : '';
        $fragment  = isset($parsed_url['fragment']) ? '#' . $parsed_url['fragment'] : '';

        return "{$scheme}{$authority}{$user}{$pass}{$host}{$port}{$path}{$query}{$fragment}";
    }