URL组装(带域名端口) 支持不同URL模式
eg: \Cml\Http\Response::fullUrl('Home/Blog/cate/id/1')

@param string $url URL表达式 路径/控制器/操作/参数1/参数1值/.....
@param bool $echo 是否输出  true输出 false return

@return string
1182
public static function fullUrl($url = '', $echo = true)
    {
        $url = Request::baseUrl() . self::url($url, false);
        if ($echo) {
            echo $url;
            return '';
        } else {
            return $url;
        }
    }
1038710
public function getUrlWithoutQueryString( $url )
    {
        if ( strpos( $url, '?' ) !== false )
        {
            $url = substr( $url, 0, strpos( $url, '?' ) );
        }

        return $url;
    }
1078184
public static function parseResourceUrl($resource = '', $echo = true)
    {
        //简单判断没有.的时候当作是目录不加版本号
        $resource = ltrim($resource, '/');
        $isDir = strpos($resource, '.') === false ? true : false;
        if (Cml::$debug) {
            $file = Response::url("cmlframeworkstaticparse/{$resource}", false);
            if (Config::get('url_model') == 2) {
                $file = str_replace(Config::get('url_html_suffix'), '', $file);
            }

            $isDir || $file .= (Config::get("url_model") == 3 ? "&v=" : "?v=") . 0;//Cml::$nowTime;
        } else {
            $file = rtrim(Config::get("static__path", Cml::getContainer()->make('cml_route')->getSubDirName()), '/') . '/' . $resource;
            $isDir || $file .= "?v=" . Config::get('static_file_version');
        }
        if ($echo) {
            echo $file;
            return '';
        } else {
            return $file;
        }
    }
1312558
public function parseUrl($url) {
		$url = parse_url($url);
		$url['vars'] = array();
		if (!isset($url['fragment'])) {
			$url['fragment'] = null;
		}
		if (isset($url['query'])) {
			parse_str($url['query'], $url['vars']);
		}

		return $url;
	}
351278
private function getUrl($url)
	{
		$ch = curl_init();
		curl_setopt($ch,CURLOPT_URL,$url);
		curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
		curl_setopt($ch,CURLOPT_HEADER,0);
		// curl_setopt($ch, CURLOPT_ENCODING, "");
		$output = curl_exec($ch);
		curl_close($ch);
	    return $output;
	}
736654
protected static function getUrl($url)
    {
        Craft::debug('Fetching JSON from: '.$url, __METHOD__);

        $ch = curl_init();
        curl_setopt_array(
            $ch,
            [
                CURLOPT_URL => $url,
                CURLOPT_RETURNTRANSFER => true,
                CURLOPT_FOLLOWLOCATION => true,
                CURLOPT_MAXREDIRS => 5,
                CURLOPT_CONNECTTIMEOUT => 5,
            ]
        );
        $data = curl_exec($ch);

        $errorNumber = curl_errno($ch);
        $errorMessage = curl_error($ch);
        curl_close($ch);

        if ($errorNumber > 0) {
            Craft::warning('cURL got an error: '.$errorNumber.', '.$errorMessage, __METHOD__);
            return false;
        }

        return $data;
    }
528963
public function getUrl($url)
    {
        if (!$url || starts_with($url, ['#', '//', 'mailto:', 'tel:', 'http'])) {
            return $url;
        }

        // Get URL root
        $root = $this->app->getSetting('url');

        $url = trim($root, '/') . '/' . trim($url, '/');

        // Force trailing slash
        if ($this->app->getSetting('url_trailing_slash', false)
            && ! strrchr(basename($url), '.')
        ) {
            $url = "{$url}/";
        }

        return $url;
    }
69551
protected function buildUrl($url)
    {
        if (strpos($url, '://') || 0 === strpos($url, '/')) {
            return $url;
        } elseif ($url === '') {
            return $url;
        } else {
            return Url::build($url);
        }
    }
152643
public function processUrl($url)
    {
        if (strpos($url, '::') !== false) {
            list($folder, $asset) = explode('::', $url, 2);
        } else {
            $folder = null;
            $asset = $url;
        }

        if (empty($asset)) {
            return false;
        }

        return array(
            'folder' => $folder,
            'asset' => $asset
        );
    }
848710
public static function getHostFromUrl($url)
    {
        $parsedUrl = parse_url($url);

        if (empty($parsedUrl['host'])) {
            return;
        }

        return Common::mb_strtolower($parsedUrl['host']);
    }
99661
public static function params($url) {
        $path  = explode('?', $url)[0];
        $query = parse_url($url, PHP_URL_QUERY);
        if ($query) {
            return site_url($path, $query);
        } else {
            return false;
        }
    }
655240
public static function getPathAndQueryFromUrl($url)
    {
        $parsedUrl = parse_url($url);
        $result = '';
        if (isset($parsedUrl['path'])) {
            if (substr($parsedUrl['path'], 0, 1) == '/') {
                $parsedUrl['path'] = substr($parsedUrl['path'], 1);
            }
            $result .= $parsedUrl['path'];
        }
        if (isset($parsedUrl['query'])) {
            $result .= '?' . $parsedUrl['query'];
        }
        return $result;
    }
106624
public static function url($url) {
		if (
			is_array($url)
			|| (is_string($url) && (preg_match('@^' . implode('|', Common::$uriSchemes) . ':@i', $url) || preg_match('@^#@i', $url)))
		) {
			return $url;
		}

		// Reset current language that gets changed by `I18n.I18nRoute::parse()`.
		$reset = Configure::check('Config.language') && $lang = Configure::read('Config.language');
		$parsed = Router::parse($url);
		if ($reset) Configure::write('Config.language', $lang);

		if ($parsed === false) {
			return $url;
		}

		if (!empty($parsed['pass'])) {
			$parsed = array_merge($parsed, $parsed['pass']);
			unset($parsed['pass']);
		}

		if (!empty($parsed['named'])) {
			foreach ($parsed['named'] as $param => $val) {
				$parsed[$param] = $val;
			}
			unset($parsed['named']);
		}

		if (array_key_exists('lang', $parsed) && strpos($url, $parsed['lang']) !== 1) {
			unset($parsed['lang']);
		}

		return $parsed;
	}
483475
public static function image(string $url): bool
    {
        $javascript_loop = 0;
        $timeout = 15;
        $url = str_replace("&amp;", "&", urldecode(trim($url)));

        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Firefox/52.0");
        curl_setopt($ch, CURLOPT_REFERER, $url);

        curl_setopt($ch, CURLOPT_COOKIEJAR, tempnam("/tmp", "CURLCOOKIE"));
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
        curl_setopt($ch, CURLOPT_ENCODING, "gzip, deflate, br");
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_AUTOREFERER, true);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);    # required for https urls
        curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
        curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
        curl_setopt($ch, CURLOPT_MAXREDIRS, 10);

        $content = curl_exec($ch);
        $response = curl_getinfo($ch);
        curl_close($ch);

        if ($response['http_code'] == 301 || $response['http_code'] == 302)
            return false;
        elseif ($response['http_code'] !== 200 || ((preg_match("/>[[:space:]]+window\.location\.replace\('(.*)'\)/i", $content, $value) || preg_match("/>[[:space:]]+window\.location\=\"(.*)\"/i", $content, $value)) && $javascript_loop < 5))
            return false;
        elseif (!preg_match('/image/i', $response['content_type']) || empty($content) || $content == '')
            return false;

        return true;
    }
803643
public function webalizeUrl(string $url) : string
    {
        $regex = PageRepository::URL_REGEX;

        if (preg_match("/{$regex}/", $url) === FALSE)
        {
            throw new InvalidArgumentException('Url contains wrong characters. Allowed characters are \'a-z, 0-9, slash, dash\'');
        }

        $url = preg_replace('~-{2,}~', '-', $url);
        $url = preg_replace('~/{2,}~', '/', $url);
        $url = trim($url, '-/');

        return $url;
    }
548823
public static function url($url){

		$url = static::_nullValue($url);
		if(!$url){

			return $url;
		}

		$query = parse_url($url, PHP_URL_QUERY);
		if(!$query){

			return $url;
		}

		parse_str($query, $query_parts);

		// First urldecode to be sure that we do not re-encode the query parts.
		$query_parts = array_map('static::_nested_urldecode', $query_parts);

		// http_build_query will take care of the urlencode.
		return strtok($url, '?') . '?' . http_build_query($query_parts);
	}
27052
public static function getTinyUrl($url)
    {
        if (strpos($url, 'http') !== 0) {
            $url = 'http://'.$url;
        }

        $gettiny = self::curl('http://tinyurl.com/api-create.php?url='.$url);

        if (isset($gettiny) && !empty($gettiny)) {
            return $gettiny;
        }

        return false;
    }