Helper method for extracting variables via Regex from a passed in URL
@param $url
@return array
971277
protected function extractUrlVariables($url){
        $variables = array();
        $pattern = "/(\\".static::$_URL_VAR_CHARACTER.".*?[^\\/]*)/";
        if (preg_match($pattern,$url,$matches)){
            array_shift($matches);
            foreach($matches as $match){
                $variables[] = $match[0];
            }
        }
        return $variables;
    }
1075802
public function discover(string $url) : array
    {
        $explorer = new Explorer($this->client, $this->logger);

        return $explorer->discover($url);
    }
935403
static public function getHeaders($url)
    {
        $ch = curl_init($url);
        curl_setopt($ch, CURLOPT_NOBODY, true);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, false);
        curl_setopt($ch, CURLOPT_HEADER, false);
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
        curl_setopt($ch, CURLOPT_MAXREDIRS, 3);
        curl_exec($ch);
        $headers = curl_getinfo($ch);
        curl_close($ch);

        return $headers;
    }
347777
public static function getDomainFromURL($url)
	{
		$url = str_replace(self::getProtocolFromURL($url) . '://', '', $url);
		
		return explode('/', $url)[0];
	}
938301
public static function extractUrl($url)
    {
        if (is_string($url)) {
            // Extract the URL from a given CSS URL value|string
            //
            // Examples:
            // - "http://www.example.com"
            // - 'http://www.example.com'
            // - url("http://www.example.com")
            // - url( 'http://www.example.com' )
            // - url(http://www.example.com)
            // - url( http://www.example.com )
            // - url("http://www.example.com?escape=\"escape\"")
            //
            // "Parentheses, whitespace characters, single quotes (') and double quotes (") appearing in a URL must be
            // escaped with a backslash so that the resulting value is a valid URL token"
            $url = Placeholder::replaceStringPlaceholders($url);
            $url = preg_replace('/^url\(|\)$/', '', $url);
            $url = str_replace(["\\(", "\\)", "\\ ", "\\'", "\\\""], ["(", ")", " ", "'", "\""], $url);
            $url = preg_replace('/^(["\'])(.*)\g{1}$/', '\\2', $url);
            $url = urldecode($url);

            return $url;
        } else {
            throw new \InvalidArgumentException(
                "Invalid type '" . gettype($url). "' for argument 'url' given."
            );
        }
    }
471149
private function parseUrl($url) {
        $var  =  array();
        if(false !== strpos($url,'?')) { // 操作?参数1=值1&参数2=值2...
            $info   =   parse_url($url);
            $path   =   $info['path'];
            parse_str($info['query'],$var);
        }else{ // 操作
            $path   =   $url;
        }
        $var[C('VAR_ACTION')] = $path;
        return $var;
    }
1071545
protected function extractVariables($variablesFile)
    {
        $str   = file_get_contents($variablesFile);
        $parts = explode(';', preg_replace('/(\/\/.*?\n|\s\n|\s{2,})/', '', $str));
        $vars  = array();

        foreach ($parts as $part) {
            $varMeta = explode(':', $part);
            if (empty($varMeta[0]) || empty($varMeta[1])) {
                continue;
            }
            $vars[substr(trim($varMeta[0]), 1)] = trim($varMeta[1]);
        }

        return $vars;
    }
1162887
public static function url_parser($url)
    {
        $regex = '/(?<=v=|v\/|vi=|vi\/|youtu.be\/|embed\/)([a-zA-Z0-9_-]{11})/';

        if (!empty($url)) {
            //full youtube URL
            if (strpos($url, 'youtu') !== false) {
                if (preg_match($regex, $url, $matches)) {
                    return $matches[1];
                }
            } elseif (strlen($url) == 11) {
                return $url;
            }
        }

        return false;
    }
985665
private function getQueryParameterFromUrl($url)
    {
        $parameters = array();
        foreach (\preg_split('/&(amp;)?/i', \preg_split('/[?]/ui', $url)[1]) as $value) {
            $chunks                 = \explode('=', $value);
            $parameters[$chunks[0]] = $chunks[1];
        }

        return $parameters;
    }
36621
public function parseUrl($url) : array
    {
        $url = (string) $url;

        $parsedUrl = $this->doParseUrl($url);

        if ($parsedUrl === []) {
            throw new InvalidArgumentException(sprintf('Invalid url %s', $url));
        }

        $parsedUrl = array_merge(self::$defaultParts, $parsedUrl);

        if (isset($parsedUrl['host'])) {
            $parsedUrl['canonical'] = implode('.', array_reverse(explode('.', $parsedUrl['host']))) . ($parsedUrl['path'] ?? '') . (isset($parsedUrl['query']) ? '?' . $parsedUrl['query'] : '');

            $parsedUrl['resource'] = $parsedUrl['path'] ?? '';

            if (isset($parsedUrl['query'])) {
                $parsedUrl['resource'] .= '?' . $parsedUrl['query'];
            }
        }

        return $parsedUrl;
    }
729114
private function match(string $url): ?array
    {
        $path = \trim(\explode('?', $url, 2)[0], self::SEPARATOR_TRIM);

        $key = $this->prefix . '_' . $path;
        $result = self::optimizeGet($key);
        if (!empty($result)) {
            return $result;
        }

        $parts = \explode('/', $path);
        if (!isset($parts[1]) && $parts[0] === '') {
            $parts = [];
        }

        $params = [];
        $current = $this->routes;
        foreach ($parts as $v) {
            if (isset($current['children'][$v])) {
                $current = $current['children'][$v];
                continue;
            }

            if ($current['regexps'] !== []) {
                foreach ($current['regexps'] as $regexp => $route) {
                    if (\preg_match($regexp, $v)) {
                        $current = $route;
                        $params[$current['name']] = $v;
                        continue 2;
                    }
                }
            }

            if (!isset($current['others'])) {
                return null;
            }

            $current = $current['others'];
            $params[$current['name']] = $v;
        }

        $result = [
            'methods' => $current['methods'],
            'route' => $current['route'],
            'params' => $params,
        ];

        self::optimizeSet($key, $result);

        return $result;
    }
1180065
public static function extractHost($url)
    {
        $parsedUrl = parse_url($url);

        if (count($parsedUrl) == 1 && isset($parsedUrl['path'])) {
            $host = $parsedUrl['path'];
        } else {
            $host = $parsedUrl['host'];
        }

        if (substr($host, 0, 4) == 'www.') {
            $host = substr($host, 4);
        }

        return $host;
    }
132893
public static function getParameters($url)
    {
        if (!$url) {
            return false;
        }
        $urlQuery = [];
        if ($query = parse_url($url)) {
            $query = explode('&', $query);
            foreach ($query as $item) {
                list($key, $value) = explode('=', $item);
                $urlQuery[$key] = $value;
            }
        }
        return $urlQuery;
    }
228752
public function matches($url)
    {
        $pattern = $this->getRegexPattern();

        if (preg_match($pattern, $url, $matches)) {

            // Remove entries with int keys to filter out only named matches
            foreach ($matches as $key => $value) {
                if (is_int($key)) {
                    unset($matches[$key]);
                }
            }

            return $matches;
        }

        return false;
    }
345421
public static function splitUrl($url) {
		$splitData = array();
		if(preg_match('/(https?)*(:\/\/)*(.*)/', $url, $matches)) {
			$splitData[] = (isset($matches[1]) && !empty($matches[1])) ? $matches[1] : 'http';
			$splitData[] = (isset($matches[3]) && !empty($matches[3])) ? $matches[3] : '';
		}
		return $splitData;
	}
953389
public static function _parse_url_query($url)
    {
        $array = parse_url($url);
        $query = $array['query'];

        $queryParts = explode('&', $query);

        $params = array();
        foreach ($queryParts as $param) {
            $item = explode('=', $param);
            $params[$item[0]] = empty($item[1]) ? '' : $item[1];
        }

        return $params;
    }
336467
public function urlToFormParameters($url)
    {
        $query = parse_url($url, PHP_URL_QUERY);
        $vars = array();
        parse_str($query, $vars);
        return $this->valuesToFormParameters($vars, null);
    }