@param Url $url

@return false|Location
967860
public function urlMatches(Url $url)
    {
        $currentPath = $this->branches->getPath();
        $urlSegments = array();

        foreach ($url->getSegments() as $urlSegment) {
            $found = false;
            $realPathSegment = $urlSegment;
            $realUrlSegment = $urlSegment;

            /** @var DirectoryIterator $nodePath */
            foreach (new RecursiveDirectoryIterator($currentPath, FilesystemIterator::SKIP_DOTS) as $nodePath) {
                if ($found) {
                    break;
                }

                $pathSegment = $nodePath->getFilename();

                if (($realUrlSegment = $this->segmentMatches($urlSegment, $pathSegment))) {
                    $found = true;
                    $realPathSegment = $pathSegment;
                }
            }

            if (!$found) {
                return false;
            }

            $currentPath .= '/'.$realPathSegment;
            $urlSegments[] = $realUrlSegment;
        }

        $realUrl = new Url(implode('/', $urlSegments));

        return new Location($realUrl, $currentPath);
    }
449028
public function setURL($url = '')
    {
        try {
            if (mb_strlen($url) > 0) {
                if (substr($url, 0, 8) == 'https://') {
                    $this->isSSL = TRUE;
                    $this->debug->debug(__FUNCTION__, 'Set SSL: ' . $this->isSSL);
                } elseif (substr($url, 0, 7) == 'http://') {
                    $this->isSSL = TRUE;
                    $this->debug->debug(__FUNCTION__, 'Set SSL: ' . $this->isSSL);
                }
            }
            $this->url = $url;
        }
        catch (Exception $e) {
            $this->url = NULL;
            $message   = "Error: " . __CLASS__ . ": Invalid protocol specified. URL must start with http:// or https:// - " . $e->getFile() . ' - Line: ' . $e->getLine() . ' - Code: ' . $e->getCode() . ' - Message: ' . $e->getMessage();
            $this->debug->error(__FUNCTION__, $message);

            return $message;
        }
        $this->debug->debug(__FUNCTION__, 'Endpoint URL to Request: ', $this->url);

        return $this;
    }
196414
public function findByUrl($url)
    {
        $this->url = $url;
        $url = RouterHelper::normalizeUrl($url);

        /**
         * @event cms.router.beforeRoute
         * Fires before the CMS Router handles a route
         *
         * Example usage:
         *
         *     Event::listen('cms.router.beforeRoute', function ((string) $url, (\Cms\Classes\Router) $thisRouterInstance) {
         *         return \Cms\Classes\Page::loadCached('trick-theme-code', 'page-file-name');
         *     });
         *
         */
        $apiResult = Event::fire('cms.router.beforeRoute', [$url, $this], true);
        if ($apiResult !== null) {
            return $apiResult;
        }

        for ($pass = 1; $pass <= 2; $pass++) {
            $fileName = null;
            $urlList = [];

            $cacheable = Config::get('cms.enableRoutesCache');
            if ($cacheable) {
                $fileName = $this->getCachedUrlFileName($url, $urlList);
                if (is_array($fileName)) {
                    list($fileName, $this->parameters) = $fileName;
                }
            }

            /*
             * Find the page by URL and cache the route
             */
            if (!$fileName) {
                $router = $this->getRouterObject();
                if ($router->match($url)) {
                    $this->parameters = $router->getParameters();

                    $fileName = $router->matchedRoute();

                    if ($cacheable) {
                        if (!$urlList || !is_array($urlList)) {
                            $urlList = [];
                        }

                        $urlList[$url] = !empty($this->parameters)
                            ? [$fileName, $this->parameters]
                            : $fileName;

                        $key = $this->getUrlListCacheKey();
                        Cache::put(
                            $key,
                            base64_encode(serialize($urlList)),
                            Config::get('cms.urlCacheTtl', 1)
                        );
                    }
                }
            }

            /*
             * Return the page
             */
            if ($fileName) {
                if (($page = Page::loadCached($this->theme, $fileName)) === null) {
                    /*
                     * If the page was not found on the disk, clear the URL cache
                     * and repeat the routing process.
                     */
                    if ($pass == 1) {
                        $this->clearCache();
                        continue;
                    }

                    return null;
                }

                return $page;
            }

            return null;
        }
    }
160275
protected function _locate($url)
    {
        //Locate the template
        if (!$file = $this->getObject('template.locator.factory')->locate($url)) {
            throw new InvalidArgumentException(sprintf('The template "%s" cannot be located.', $url));
        }

        return $file;
    }
894718
public function fetchUrl($url)
    {
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

        // HTTPS
        if (strpos($url, 'https://') !== false) {
            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
            curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
        }

        $res = curl_exec($ch);
        curl_close($ch);

        return $res;
    }
709842
public function locate($url)
    {
        $result     = array();
        $identifier = $this->getIdentifier($url);

        $info   = array(
            'url'     => $identifier,
            'locale'  => $this->getLocale(),
            'path'    => '',
            'domain'  => $identifier->getDomain(),
            'package' => $identifier->getPackage(),
        );

        return $this->find($info);
    }
16907
public function matches($url)
    {
        $infos = parse_url($url);

        if ($this->expired()) {
            return false;
        }

        if (!$this->matchesScheme($infos['scheme'])) {
            return false;
        }

        if (!$this->matchesDomain($infos['host'])) {
            return false;
        }

        return $this->matchesPath($infos['path']);
    }
1231812
public function validRedirectUrl($url)
    {
        $root = $this->app->uri->root;

        if (strpos($url, '/') === 0) {
            return $url;
        }

        if (stripos($url, $root) !== 0) {
            return $root;
        }

        return $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
        );
    }
139747
public static function location($self, $url = null) 
    {
        // TODO if ! $url return actual location ???
        $xhr = isset($self->document->xhr)
        ? $self->document->xhr
        : null;
        $xhr = phpQuery::ajax(
            array(
            'url' => $url,
            ), $xhr
        );
        $return = false;
        if ($xhr->getLastResponse()->isSuccessful()) {
            $return = phpQueryPlugin_WebBrowser::browserReceive($xhr);
            if (isset($self->document->WebBrowserCallback)) {
                phpQuery::callbackRun(
                    $self->document->WebBrowserCallback,
                    array($return)
                );
            }
        }
        return $return;
    }
283127
private function fixUriParts($url)
    {
        $position = Str::strpos($url, '?') ?: Str::strpos($url, '#');

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

        return Str::substr($url, 0, $position) . '/' . Str::substr($url, $position);
    }
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;
	}
639017
protected function getUrlStatus($url)
    {
        if($this->isValidUrl($url)) {
            ini_set('allow_url_fopen', 1);
            $url = @get_headers($url, 1);
            if($url) {
                $status = explode(' ',$url[0]);
                return (int) $status[1];
            }
        }
        else {
            return 404;
        }
    }
852135
public function getResourceAddress($url){
        $url = $this->resolve($url);
        
        $p = strpos($url,'?');
        $p = $p === false ? strpos($url,'#') : $p;
        
        return $p === false ? $url : substr($url, 0, $p);
    }
675200
public static function getHeaderFromUrl($url) {
		// @codingStandardsIgnoreStart
		$url = @parse_url($url);
		// @codingStandardsIgnoreEnd
		if (empty($url)) {
			return false;
		}

		$url = array_map('trim', $url);
		$url['port'] = (!isset($url['port'])) ? '' : (':' . (int)$url['port']);
		$path = (isset($url['path'])) ? $url['path'] : '';

		if (empty($path)) {
			$path = '/';
		}

		$path .= (isset($url['query'])) ? "?$url[query]" : '';

		$defaults = [
			'http' => [
				'header' => "Accept: text/html\r\n" .
					"Connection: Close\r\n" .
					"User-Agent: Mozilla/5.0 (Windows NT 6.2; WOW64)\r\n",
			]
		];
		stream_context_get_default($defaults);

		if (isset($url['host']) && $url['host'] !== gethostbyname($url['host'])) {
			$url = "$url[scheme]://$url[host]$url[port]$path";
			$headers = get_headers($url);
			if (is_array($headers)) {
				return $headers;
			}
		}
		return false;
	}
1253106
public function byURL($url) {
        $URL = \Convert::raw2sql($url);
        return $this->owner->filter('URLSegment', $URL)->first();
    }
1010178
public function findURL($url)
    {
        $nb_site_target = $this->getItem($url, self::INDEX_URL_STATIC);
        if ($nb_site_target === null) {
            //$nb_site_target = $this->findByRegExpr(self::INDEX_URL_REGEXP, $url);
        }

        return $nb_site_target;
    }