Constructs absolute URL from Request object.

@param \Nette\Application\Request $appRequest
@param \Nette\Http\Url $refUrl
@throws \Nette\InvalidStateException
@return string|NULL
195599
public function constructUrl(Request $appRequest, Url $refUrl)
	{
		// Module prefix not match.
		if ($this->module && !Strings::startsWith($appRequest->getPresenterName(), $this->module)) {
			return null;
		}

		$parameters = $appRequest->getParameters();
		$urlStack = array();

		// Module prefix.
		$moduleFrags = explode(":", $appRequest->getPresenterName());

		if (count($moduleFrags)) {
			foreach($moduleFrags as &$fragment) {
				$fragment = $this->presenter2path($fragment);
			}
		}

		$resourceName = array_pop($moduleFrags);
		$urlStack += $moduleFrags;

		if (isset($parameters['associations']) && is_array($parameters['associations'])) {
			$associations = & $parameters['associations'];

			foreach ($associations as $key => $value) {
				$urlStack[] = $key;
				$urlStack[] = $value;
			}
		}

		$urlStack[] = $resourceName;
		if(isset($parameters['specific_action']) && $parameters['specific_action']) {
			$urlStack[] = $this->action2path($parameters['specific_action']);
		}

		if (isset($parameters['id']) && is_scalar($parameters['id'])) {
			$urlStack[] = $parameters['id'];
		}

		$url = $q = $refUrl->getBaseUrl() . implode('/', $urlStack);


		if(isset($parameters['query']) && count($parameters['query'])) {
			$sep = ini_get('arg_separator.input');
			$query = http_build_query($parameters['query'], '', $sep ? $sep[0] : '&');
			$url .= '?' . $query;
		}

		return $url;
	}
732158
public function getReferer() : ?Url
    {
        $referer = $this->getFirstHeader('Referer');

        if ($referer === null) {
            return null;
        }

        try {
            return new Url($referer);
        } catch (\InvalidArgumentException $e) {
            return null;
        }
    }
393603
protected function createUrl($url)
    {
        // is absolute URL?
        if (strpos($url, '://')) {
            return Url::createFromUrl($url);
        }

        // only query and path matters in relative url
        $url = Url::createFromUrl($url);
        $query = $this->baseUrl->getQuery();
        $path = $this->baseUrl->getPath();

        $query->modify($url->getQuery());
        $path->append($url->getPath());

        return $this->baseUrl->setQuery($query)->setPath($path);
    }
783680
public function getPageLinkWrapper($url, $page, $rel = null)
    {
        $rel = is_null($rel) ? '' : ' rel="'.$rel.'"';
        $class = Config::get('pagination::scroll.infinite_more_link_class');

        return '<li><a class='.$class.' href="'.$url.'"'.$rel.'>'.$page.'</a></li>';
    }
421831
protected static function processLinkUrl($linkUrl)
    {
        static $absRefPrefix = null;
        static $absRefPrefixLength = 0;
        $ret = $linkUrl;
        $tsfe = self::getTsfe();


        // Fetch abs ref prefix if available/set
        if ($absRefPrefix === null) {
            if (!empty($tsfe->tmpl->setup['config.']['absRefPrefix'])) {
                $absRefPrefix       = $tsfe->tmpl->setup['config.']['absRefPrefix'];
                $absRefPrefixLength = strlen($absRefPrefix);
            } else {
                $absRefPrefix = false;
            }
        }

        $absRefPrefixLengthTmp = $absRefPrefixLength; //makes sure we do not write back to static variable

        // remove abs ref prefix
        if ($absRefPrefix !== false && strpos($ret, $absRefPrefix) === 0) {
            $parsedUrl = parse_url($linkUrl);
            if ($parsedUrl !== false
                && $parsedUrl['path'] === $absRefPrefix
                && substr($absRefPrefix, -1) === '/'  //sanity check: must end with /
            ) {
                //for root pages: treat '/' like a suffix, not like a prefix => don't remove last '/' in that case!
                //This ensures that for an absRefPrefix = '/abc/' or '/' we return '/' instead of empty strings
                $absRefPrefixLengthTmp--;
            }

            $ret = substr($ret, $absRefPrefixLengthTmp);
        }

        return $ret;
    }
972644
public function getRedirectToRoute($route, $parameters = [], $referenceType = UrlGeneratorInterface::ABSOLUTE_PATH, $status = Response::HTTP_FOUND, $routeFragment = null)
    {
        $url = $this->getRouter()->generate($route, $parameters, $referenceType);
        if (null !== $routeFragment) {
            $url = sprintf('%s#%s', $url, $routeFragment);
        }

        return new RedirectResponse($url, $status);
    }
718066
protected function _redirectUrl($default = null)
    {
        $request = $this->_request();

        if (!empty($request->getData('_redirect_url'))) {
            return $request->getData('_redirect_url');
        }
        if (!empty($request->getQuery('_redirect_url'))) {
            return $request->getQuery('_redirect_url');
        }
        if (!empty($request->getData('redirect_url'))) {
            return $request->getData('redirect_url');
        }
        if (!empty($request->getQuery('redirect_url'))) {
            return $request->getQuery('redirect_url');
        }

        return $default;
    }
337352
public function url($project = null, $ref = null, $doc = null)
    {
        $uri = $this->config('base_route');

        if ( ! is_null($project) )
        {
            if ( ! $project instanceof Project )
            {
                $project = $this->getProject($project);
            }
            $uri .= '/' . $project->getName();


            if ( ! is_null($ref) )
            {
                $uri .= '/' . $ref;
            }
            else
            {
                $uri .= '/' . $project->getDefaultRef();
            }


            if ( ! is_null($doc) )
            {
                $uri .= '/' . $doc;
            }
        }

        return url($uri);
    }
1296216
public function getRedirectUrl($returnTo = null)
    {
        $settings = $this->auth->getSettings();
        $authnRequest = new OneLogin_Saml2_AuthnRequest($settings);
        $parameters = array('SAMLRequest' => $authnRequest->getRequest());
        if (!empty($returnTo)) {
            $parameters['RelayState'] = $returnTo;
        } else {
            $parameters['RelayState'] = OneLogin_Saml2_Utils::getSelfRoutedURLNoQuery();
        }
        $url = OneLogin_Saml2_Utils::redirect($this->auth->getSSOurl(), $parameters, true);
        return $url;
    }
1139874
protected function buildUrl(AbstractModel $subject, AbstractModel $parent = null, $appendUrl = null, $docType = null)
    {
        if (is_null($docType)) {
            $docType = substr($this->mapper->getContentType(), strpos($this->mapper->getContentType(), '/') + 1);
        }

        $url = $this->baseUri;
        if (!is_null($parent) && intval($parent->getId()) > 0) {
            $url .= '/' . $this->mapTypeName($parent) . '/' . $parent->getId();
        }
        $url .= '/' . $this->mapTypeName($subject);
        if (intval($subject->getId()) > 0) {
            $url .= '/' . $subject->getId();
        }
        if (!is_null($appendUrl)) {
            $url .= $appendUrl;
        }
        return $url . '.' . $docType;
    }
942328
function urlFor($internalUri, $locale = NULL){
        $internalUri= ltrim($internalUri, '/');
        if($locale == NULL)return $this->request->realBaseUrl . $internalUri;
        else return $this->request->realBaseUrl . $locale . '/' . $internalUri;
    }
756301
public function setUrl(string $url) : Request
    {
        $components = parse_url($url);

        if ($components === false) {
            throw new \InvalidArgumentException('The URL provided is not valid.');
        }

        if (! isset($components['scheme'])) {
            throw new \InvalidArgumentException('The URL must have a scheme.');
        }

        $scheme = strtolower($components['scheme']);

        if ($scheme !== 'http' && $scheme !== 'https') {
            throw new \InvalidArgumentException(sprintf('The URL scheme "%s" is not acceptable.', $scheme));
        }

        $isSecure = ($scheme === 'https');

        if (! isset($components['host'])) {
            throw new \InvalidArgumentException('The URL must have a host name.');
        }

        $host = $components['host'];

        if (isset($components['port'])) {
            $port = $components['port'];
            $hostHeader = $host . ':' . $port;
        } else {
            $port = ($isSecure ? 443 : 80);
            $hostHeader = $host;
        }

        $this->path = isset($components['path']) ? $components['path'] : '/';
        $requestUri = $this->path;

        if (isset($components['query'])) {
            $this->queryString = $components['query'];
            parse_str($this->queryString, $this->query);
            $requestUri .= '?' . $this->queryString;
        } else {
            $this->queryString = '';
            $this->query = [];
        }

        $this->setHeader('Host', $hostHeader);

        $this->host = $host;
        $this->port = $port;
        $this->isSecure = $isSecure;
        $this->requestUri = $requestUri;

        return $this;
    }
953215
public function getCropEndpoint(
        $endpoint,
        $parameters = array(),
        $absolute = UrlGeneratorInterface::ABSOLUTE_PATH
    ) {
        $parameters = array_merge($parameters, array('endpoint' => $endpoint));

        return $this->router->generate($this->routeName, $parameters, $absolute);
    }
870660
private function makeAbsoluteStr($base, $url)
    {
        if (!$url) {
            return false;
        }

        if (preg_match('!^https?://!i', $url)) {
            // already absolute
            return $url;
        }

        $base = new \SimplePie_IRI($base);

        // remove '//' in URL path (causes URLs not to resolve properly)
        if (isset($base->ipath)) {
            $base->ipath = preg_replace('!//+!', '/', $base->ipath);
        }

        if ($absolute = \SimplePie_IRI::absolutize($base, $url)) {
            return $absolute->get_uri();
        }

        return false;
    }
557481
public function currentPageUrl($parameters = [], $routePersistence = true)
    {
        if (!$currentFile = $this->page->getFileName()) {
            return null;
        }

        return $this->pageUrl($currentFile, $parameters, $routePersistence);
    }
849346
public function getUrl($page, $absolute = false, $routePrm = null)
    {
        $prm = !is_null($routePrm) ? $routePrm : $this->routePrm;
        $prm['page'] = $page;

        return $this->service->generateUrl($this->route, $prm, $absolute);
    }
200458
public function validateUrl($url)
    {
        if (empty($url)) {
            throw new \InvalidArgumentException('The field cannot be empty.');
        }

        if (!filter_var($url, FILTER_VALIDATE_URL)) {
            throw new \InvalidArgumentException('The field requires a valid URL.');
        }

        return $url;
    }