@param array $url

@return array
326984
protected function addQueryStrings(array $url) {
		if (!isset($url['?'])) {
			$url['?'] = [];
		}
		$url['?'] += $this->Controller->getRequest()->getQuery();

		return $url;
	}
237004
public function getUrlIdMap(array $urls)
    {
        $map = [];

        if (!empty($urls)) {
            $query = $this->connection->createQueryBuilder();
            $query
                ->select(
                    $this->connection->quoteIdentifier('id'),
                    $this->connection->quoteIdentifier('url')
                )
                ->from(self::URL_TABLE)
                ->where(
                    $query->expr()->in('url', ':urls')
                )
                ->setParameter(':urls', $urls, Connection::PARAM_STR_ARRAY);

            $statement = $query->execute();
            foreach ($statement->fetchAll(PDO::FETCH_ASSOC) as $row) {
                $map[$row['url']] = $row['id'];
            }
        }

        return $map;
    }
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
        );
    }
424047
public static function getSubDomain($url)
    {
        $urlInfo = static::info($url);

        return ArrayHelper::get($urlInfo, 'sub', null, true);
    }
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;
	}
1356663
private function createFullUrl($url)
    {
        if (is_array($url)) {
            $params = $url;
            if (isset($params[0])) {
                $url = (string)$params[0];
                unset($params[0]);
            } else {
                $url = '';
            }
        }

        if (!empty($this->client->baseUrl)) {
            if (empty($url)) {
                $url = $this->client->baseUrl;
            } elseif (!preg_match('/^https?:\\/\\//i', $url)) {
                $url = rtrim($this->client->baseUrl, '/') . '/' . ltrim($url, '/');
            }
        }

        if (!empty($params)) {
            if (strpos($url, '?') === false) {
                $url .= '?';
            } else {
                $url .= '&';
            }
            $url .= http_build_query($params);
        }

        return $url;
    }
37535
private function createRequestSet(string $url): array
    {
        $httpMethodList = $this->configuration->getHttpMethodList();
        $userAgentSelection = $this->getUserAgentSelection();
        $referrer = $this->configuration->getReferrer();

        $requests = [];

        foreach ($userAgentSelection as $userAgent) {
            foreach ($httpMethodList as $methodIndex => $method) {
                $headers = [
                    'user-agent' => $userAgent,
                ];

                if (!empty($referrer)) {
                    $headers['referer'] = $referrer;
                }

                $requests[] = new Request($method, $url, $headers);
            }
        }

        return $requests;
    }
1042878
public function crawl( $url ) {

		$this->parse($url);

		while( $url = array_shift($this->sitemaps) ) {

			$this->parse($url);
		}

		return $this->urls;
	}
956644
public static function multiExecGet(array $urls) : array {
		$result = [
			'success' => false,
			'error' => [],
			'data' => []
		];
		// create both cURL resources
		$ch = [];
		$mh = curl_multi_init();
		foreach ($urls as $k => $v) {
			$ch[$k] = curl_init();
			curl_setopt($ch[$k], CURLOPT_URL, $v['url']);
			curl_setopt($ch[$k], CURLOPT_HEADER, 0);
			curl_setopt($ch[$k], CURLOPT_RETURNTRANSFER, 1);
			// add handles
			curl_multi_add_handle($mh, $ch[$k]);
		}
		$active = null;
		// execute the handles
		do {
			$status = curl_multi_exec($mh, $active);
			// check for errors
			if ($status > 0) {
				$result['error'][] = curl_multi_strerror($status);
			}
		} while ($status === CURLM_CALL_MULTI_PERFORM || $active);
		// close the handles
		foreach ($ch as $k => $v) {
			$result['data'][$k] = curl_multi_getcontent($v); // get the content
			curl_multi_remove_handle($mh, $v);
			curl_close($v);
		}
		curl_multi_close($mh);
		// success
		if (empty($result['error'])) {
			$result['success'] = true;
		}
		return $result;
	}
354041
final static function normalize(string $url):string{#{{{

    if(isset(
      $_SERVER['REQUEST_SCHEME'],
      $_SERVER['REQUEST_HOST'],
      $_SERVER['REQUEST_PORT'],
      $_SERVER['REQUEST_URI'],
      $_SERVER['SERVER_PORT']
    ) || PHP_SAPI ==='cli')
      return $url;

    $arr = parse_url($url);
    if($arr===false) return '';

    $a = [
      $arr['scheme']??$_SERVER['REQUEST_SCHEME'],
      '://',
      $arr['user']??'',
      ':',
      $arr['pass']??'',
      '@',
      $arr['host']??$_SERVER['HTTP_HOST'],
      ':',
      $arr['port']??$_SERVER['SERVER_PORT'],
      substr($_SERVER['REQUEST_URI'],0, strrpos($_SERVER['REQUEST_URI'],'/')+1),
      $arr['path']??'',
      '?',
      $arr['query']??'',
      '#',
      $arr['fragment']??'',
    ];

    if(!in_array($a[0], ['http','https'])) return '';

    if($a[12]==='')            unset($a[11],$a[12]);
    if($a[14]==='')            unset($a[13],$a[14]);
    if($a[8]==80)              unset($a[7],$a[8]);
    if($a[4]==='')             unset($a[3],$a[4]);
    if($a[2]==='')             unset($a[2],$a[3],$a[4],$a[5]);
    if(strpos($a[10],'/')===0) unset($a[9]);

    while(strpos($a[10],'../')===0){
      $a[10] = substr($a[10],3);
      $a[9] = dirname($a[9]);
      if($a[9]!=='/') $a[9] .= '/';
    }

    while(strpos($a[10],'./')===0){
      $a[10] = substr($a[10],2);
    }

    if($a[10]==='.') unset($a[10]);

    return implode($a);
  }
830977
public function extractShortUrl(string $url):array {
		$urls = [$url];

		while($url = $this->extract($url)){
			$urls[] = $url;
		}

		return $urls;
	}
158329
public function loadResource(string $url, array $parameters): array
    {
        $signature = $this->createSignature($url, $parameters);
        if ($this->cache->has($signature)) {
            return $this->cache->get($signature);
        }

        $parameters['format'] = 'json';
        $parameters['api_key'] = $this->config->getApiKey();
        $url = $this->config->getApiEndpoint().$this->buildQueryUrl($url, $parameters);

        $response = $this->guzzle->request('GET', $url);
        $body = $this->processResponse($response);

        $this->cache->set($signature, $body['results']);

        return $body['results'];
    }
1349356
protected function castToArray($url)
    {
        if (is_array($url)) {
            return $url;
        }

        if (is_string($url)) {
            return $this->parseUrl($url);
        }

        if (!$url instanceof UrlContract) {
            $typeName = is_object($url) ? get_class($url) : gettype($url);
            throw new InvalidArgumentException("Now idea how to get the values of the passed url $typeName");
        }

        $array = [];

        foreach ($this->properties as $key => $default) {
            $array[$key] = $url->__get($key);
        }

        // If the url had an absolute path but no scheme we have to copy it
        if (isset($array['path'])) {
            $array['path'] = (!$url->isRelative() && !$url->scheme) ? '/'.$array['path'] : $array['path'];
        }

        return $array;
    }
748803
protected function parseUrlParams($url, &$var = [])
    {
        if ($url) {
            if ($this->getConfig('url_param_type')) {
                $var += explode('|', $url);
            } else {
                preg_replace_callback('/(\w+)\|([^\|]+)/', function ($match) use (&$var) {
                    $var[$match[1]] = strip_tags($match[2]);
                }, $url);
            }
        }
    }
905129
public static function get(string $url, array $options = []) : array {
		$result = [
			'success' => false,
			'error' => [],
			'data' => null
		];
		if (strpos($url, '?') !== false) {
			$url.= '&';
		} else {
			$url.= '?';
		}
		$url.= http_build_query2($options['params']);
		$ch = curl_init();
		curl_setopt($ch, CURLOPT_URL, $url);
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
		$result['data'] = curl_exec($ch);
		if (!empty($options['json'])) {
			$result['data'] = json_decode($result['data'], true);
		}
		curl_close($ch);
		$result['success'] = true;
		return $result;
	}
904356
protected function getOptionLinks(array $urls)
    {
        $html = '';

        foreach ($urls as $page => $url) {
            $html .= $this->getOption($url, $page);
        }

        return $html;
    }
624209
static function GatherParams($url)
    {
        $reader = new StringReader($url);
        $param = '';
        $params = array();
        $start = false;
        while (false !== ($ch = $reader->ReadChar())) {
            if ($ch == '{') {
                $start = true;
            }
            else if ($ch == '}' && $start) {
                $params[] = $param;
                $param = '';
                $start = false;
            }
            else if ($start) {
                $param .= $ch;
            }
        }
        return $params;
    }