Generate an application URL.

@param string    $url
@param null|bool $https
@param bool      $asset

@return string
344830
public static function to($url = '', $https = null, $asset = false)
    {
        $url = trim($url, '/');

        if (static::valid($url)) {
            return $url;
        }

        $root = self::format($https, $asset);

        return rtrim($root, '/') . '/' . ltrim($url, '/');
    }
836807
public function rewriteUrl(array $aMatches, \AssetsBundle\AssetFile\AssetFile $oAssetFile)
    {
        if (!isset($aMatches[1])) {
            throw new \InvalidArgumentException('Url match is not valid');
        }

        // Remove quotes & double quotes from url
        $aFirstCharMatches = null;
        $sFirstChar = preg_match('/^("|\'){1}/', $sUrl = trim($aMatches[1]), $aFirstCharMatches) ? $aFirstCharMatches[1] : '';
        $sUrl = str_ireplace(array('"', '\''), '', $sUrl);

        // Data url
        if (strpos($sUrl, 'data:') === 0) {
            return $aMatches[0];
        }

        // Remote absolute url
        if (preg_match('/^http/', $sUrl)) {
            return $aMatches[0];
        }

        // Split arguments
        if (strpos($sUrl, '?') !== false) {
            list($sUrl, $sArguments) = explode('?', $sUrl);
        }

        // Split anchor
        if (strpos($sUrl, '#') !== false) {
            list($sUrl, $sAnchor) = explode('#', $sUrl);
        }

        // Absolute url
        if (($sUrlRealpath = $this->getOptions()->getRealPath($sUrl, $oAssetFile))) {
            // Initialize asset file from url
            $oUrlAssetFile = new \AssetsBundle\AssetFile\AssetFile(array(
                'asset_file_type' => \AssetsBundle\AssetFile\AssetFile::ASSET_MEDIA,
                'asset_file_path' => $sUrlRealpath
            ));

            $sAssetFileCachePath = $this->getAssetFilesCacheManager()->getAssetFileCachePath($oUrlAssetFile);
            if (!file_exists($sAssetFileCachePath)) {
                throw new \LogicException('Media file "' . $oUrlAssetFile->getAssetFilePath() . '" used by "' . $oAssetFile->getAssetFilePath() . '" does not have been cached. Please add it into ["assets_bundle"]["assets"]["media"] configuration array');
            }

            // Define cached file path
            $oUrlAssetFile->setAssetFilePath($sAssetFileCachePath);

            // Retrieve asset file base url
            $sAssetFileBaseUrl = $this->getOptions()->getAssetFileBaseUrl($oUrlAssetFile);

            // Add argument and / or anchor to asset file base url
            $sAssetFileRealBaseUrl = $sFirstChar . $sAssetFileBaseUrl . (empty($sArguments) ? '' : '?' . $sArguments) . (empty($sAnchor) ? '' : '#' . $sAnchor) . $sFirstChar;

            // Return asset file base url
            return str_replace($aMatches[1], $sAssetFileRealBaseUrl, $aMatches[0]);
        } // Remote relative url
        elseif ($oAssetFile->isAssetFilePathUrl()) {
            return str_replace($aMatches[1], $sFirstChar . dirname($oAssetFile->getAssetFilePath()) . '/' . ltrim($sUrl, '/') . $sFirstChar, $aMatches[0]);
        } // Url is not an exising file
        else {
            throw new \LogicException('Url file "' . $sUrl . '" does not exist even relative with "' . $oAssetFile->getAssetFilePath() . '"');
        }
    }
850308
public function getImgixUrl (Asset $asset)
    {
        $url      = null;
        $domains  = $this->settings->imgixDomains;
        $volume   = $asset->getVolume();
        $assetUrl = AssetsHelper::generateUrl($volume, $asset);
        $assetUri = parse_url($assetUrl, PHP_URL_PATH);

        if ( isset($domains[ $volume->handle ]) ) {
            $builder = new UrlBuilder($domains[ $volume->handle ]);
            $builder->setUseHttps(true);
            if ($token = Imgix::$plugin->getSettings()->imgixSignedToken)
                $builder->setSignKey($token);
            $url = UrlHelper::stripQueryString($builder->createURL($assetUri));
        }


        return $url;
    }
1066384
function(url) {
            var needle = url.replace(/^https?:/, '');
            var assets = µb.availableFilterLists, asset;
            for ( var assetKey in assets ) {
                asset = assets[assetKey];
                if ( asset.content !== 'filters' ) { continue; }
                if ( typeof asset.contentURL === 'string' ) {
                    if ( asset.contentURL.endsWith(needle) ) { return assetKey; }
                    continue;
                }
                if ( Array.isArray(asset.contentURL) === false ) { continue; }
                for ( i = 0, n = asset.contentURL.length; i < n; i++ ) {
                    if ( asset.contentURL[i].endsWith(needle) ) {
                        return assetKey;
                    }
                }
            }
            return url;
        }
529684
private function geocodeUrl($https = false) {
      // HTTPS is required if an API key is set.
      if ($https || $this->getApiKey()) {
        $scheme = "https";
      }
      else {
        $scheme = "http";
      }

      $pathQueryString = self::URL_PATH . $this->getFormat() . "?" . $this->geocodeQueryString();

      if ($this->isBusinessClient()) {
        $pathQueryString .= "&signature=" . $this->generateSignature($pathQueryString);
      }

      return $scheme . "://" . self::URL_DOMAIN . $pathQueryString;
    }
643132
public static function prepare_url ($url, $absolute = false) {
		if ($url === false) {
			return false;
		}
		if ($url[0] == '#') {
			$url = static::url_with_hash($url);
		} elseif (
			substr($url, 0, 2) != '$i' &&
			substr($url, 0, 5) != 'data:' &&
			$url[0] != '/' &&
			substr($url, 0, 7) != 'http://' &&
			substr($url, 0, 8) != 'https://'
		) {
			if ($absolute) {
				return static::absolute_url($url);
			}
			return "/$url";
		}
		return $url;
	}
1055968
public function url($asset)
    {   
        $url = $this->parsePathAlias($asset, false);

        return $this->buildUrl($url);
    }
667094
public function rewriteAssetFileUrls($sAssetFileContent, \AssetsBundle\AssetFile\AssetFile $oAssetFile){
        // Callback for url rewriting
        $oRewriteUrlCallback = array($this, 'rewriteUrl');
        return preg_replace_callback('/url\(([^\)]+)\)/', function ($aMatches) use ($oAssetFile, $oRewriteUrlCallback) {
            return call_user_func($oRewriteUrlCallback, $aMatches, $oAssetFile);
        }, $sAssetFileContent);
    }
605562
public function asset($asset) : string
    {
        if (Str::contains($asset, ':') === false) {
            throw InvalidAssetPath::missingModuleName($asset);
        }
        list($name, $url) = explode(':', $asset);

        $baseUrl = str_replace(public_path() . DIRECTORY_SEPARATOR, '', $this->getAssetsPath());

        $url = $this->app['url']->asset($baseUrl . "/{$name}/" . $url);

        return str_replace(['http://', 'https://'], '//', $url);
    }
49647
public function asset($asset, $secure = null)
    {
        return url('themes/' . $this->getCurrent() . '/' . $asset, null, $secure);
    }
901721
public function get_url($forcedownload=false, $https=false) {
        if (!$this->is_readable()) {
            return null;
        }

        if ($this->lf->is_directory()) {
            return null;
        }

        $filepath = $this->lf->get_filepath();
        $filename = $this->lf->get_filename();
        $courseid = $this->context->instanceid;

        $path = '/'.$courseid.$filepath.$filename;

        return file_encode_url($this->urlbase, $path, $forcedownload, $https);
    }
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);
    }
101119
protected function _getAssetFile($url) {
		$parts = explode('/', $url);
		if ($parts[0] === 'theme') {
			$themeName = $parts[1];
			unset($parts[0], $parts[1]);
			$fileFragment = implode(DS, $parts);
			$path = App::themePath($themeName) . 'webroot' . DS;
			return $path . $fileFragment;
		}

		$plugin = Inflector::camelize($parts[0]);
		if ($plugin && CakePlugin::loaded($plugin)) {
			unset($parts[0]);
			$fileFragment = implode(DS, $parts);
			$pluginWebroot = CakePlugin::path($plugin) . 'webroot' . DS;
			return $pluginWebroot . $fileFragment;
		}

		$webroot = APP . 'webroot' . DS;
		$fileFragment = implode(DS, $parts);
		if (file_exists($webroot . $parts[0])) {
			return $webroot . $fileFragment;
		}

		$router = Router::parse($url);
		if (strpos($router['controller'], '.') !== false || strpos($router['action'], '.') !== false) {
			return 'webroot' . DS . $fileFragment;
		}
	}
844623
protected function generateStandardUrl(array $urlParameters = array(), $absolute = false)
    {
        if (parent::isCurrent())
        {
            return '#'.$this->getAnchor();
        }
        
        return parent::generateStandardUrl($urlParameters, $absolute);
    }
1309760
public function getAsseticVersionUrl($url)
    {
        $tmp = $this->getParameter('assetic_versions');

        if ($tmp && is_array($tmp)) {
            $tmpUrl = basename($url);
            $url .= '?'.(isset($tmp[$tmpUrl]) && $tmp[$tmpUrl] ? $tmp[$tmpUrl] : (isset($tmp['global']) ? $tmp['global'] : ''));
        }

        return $url;
    }
496051
public static function link(string $path, string $assetSite = null): Redirect
    {
        return self::temporary(Application::route()->asset($path, $assetSite));
    }
839513
protected function getAssetScheme($asset)
    {
        if (starts_with($asset, ['//', 'http://', 'https://'])) {
            return $asset;
        }

        if (substr($asset, 0, 1) == '/') {
            $asset = Url::asset($asset);
        }

        return $asset;
    }