Replace absolute urls with relative path
@return Hups\Util\HTMLCompressor
963511
public function replaceAbsoluteUrls($currentHost = true)
    {
        $hosts = array();

        if ($currentHost === true)
        {
            $hosts[] = $_SERVER["HTTP_HOST"];
        }
        elseif (is_array($currentHost))
        {
            foreach ($currentHost as $h)
            {
                $hosts[] = $h;
            }
        }

        foreach ($hosts as $h)
        {
            $this->filteredHtml = preg_replace("/=([\"'])((http[s]?:\/\/)?".$h.")/usi", '=$1', $this->filteredHtml);
        }
        
        return $this;
    }
1162102
public function absoluteUrlFilter($string)
    {
        $url    = $this->grav['uri']->base();
        $string = preg_replace('/((?:href|src) *= *[\'"](?!(http|ftp)))/i', "$1$url", $string);

        return $string;

    }
938227
public function normalize() {
		// remove whitespace from the beginning
		$this->str = ltrim($this->str);

		// ensure that there is exactly one forward slash at the beginning
		$this->str = '/'.ltrim($this->str, '/');

		// remove whitespace from the end
		$this->str = rtrim($this->str);


		return $this;
	}
1319068
protected function prepareBasePath()
    {
        $baseUrl = $this->getBaseUrl();
        if (empty($baseUrl)) {
            return '';
        }

        $filename = basename($this->server->get('SCRIPT_FILENAME'));
        if (basename($baseUrl) === $filename) {
            $basePath = \dirname($baseUrl);
        } else {
            $basePath = $baseUrl;
        }

        if ('\\' === \DIRECTORY_SEPARATOR) {
            $basePath = str_replace('\\', '/', $basePath);
        }

        return rtrim($basePath, '/');
    }
979115
public function uri() {
		$uri = self::uriTrim();
		$webRoot = self::webRoot();
		$uri = str_replace($webRoot, '', $uri);
		$uri = trim($uri, '/');
		return $uri;
	}
281358
static public function buildAbsolutePath($relative_path, $basepath) {
        if (strpos($relative_path, static::PATH_SEGMENT_SEPARATOR) === 0) {
            return static::normalizePath($relative_path);
        }
        $basedir = static::dirname($basepath);
        if ($basedir == '.' || $basedir == static::PATH_SEGMENT_SEPARATOR || $basedir == '\\' || $basedir == DIRECTORY_SEPARATOR) $basedir = '';
        return static::normalizePath($basedir . self::PATH_SEGMENT_SEPARATOR . $relative_path);
    }
287729
public function getMetaAbsoluteLink()
    {
        if ($this->owner->hasMethod('AbsoluteLink')) {
            return $this->owner->AbsoluteLink();
        } elseif ($this->owner->AbsoluteLink) {
            return $this->owner->AbsoluteLink;
        }
    }
713294
def build_absolute_uri(request, relative_url):
    """"""
    webroot = getattr(settings, 'WEBROOT', '')
    if webroot.endswith("/") and relative_url.startswith("/"):
        webroot = webroot[:-1]

    return request.build_absolute_uri(webroot + relative_url)
1341198
public function getAbsoluteUrl(): string
    {
        if (!$this->absoluteUrl) {
            // Guessing we're a http endpoint.
            $this->absoluteUrl = 'http://'.
                ($this->getHeader('Host') ?? 'localhost').
                $this->getUrl();
        }

        return $this->absoluteUrl;
    }
378351
public static function url_to_file_system( $url ) {
		$url_parts = parse_url($url);
		$url_parts['path'] = apply_filters('timber/URLHelper/url_to_file_system/path', $url_parts['path']);
		$path = ABSPATH.$url_parts['path'];
		$path = str_replace('//', '/', $path);
		return $path;
	}
1132903
public function getWebroot()
    {
        if ($this->_webroot === null) {
            $this->_webroot = realpath(realpath($this->basePath) . DIRECTORY_SEPARATOR . $this->webrootDirectory);
        }
        
        return $this->_webroot;
    }
882564
public function fixRelativePaths($content,$path,$targetDir=null) {
		// Rewrite relative URLs in CSS
		$f3=$this->f3;
		$method=$f3->get('ASSETS.fixRelativePaths');
		if ($method!==FALSE) {
			$webBase=$f3->get('BASE');
			// fix base path (resolve symbolic links)
			$basePath=$f3->fixslashes(realpath(
				$f3->fixslashes($_SERVER['DOCUMENT_ROOT'].$webBase)).DIRECTORY_SEPARATOR);
			// parse content for URLs
			$content=preg_replace_callback(
				'/\b(?<=url)\((?:([\"\']?)(.+?)((\?.*?)?)\1)\)/s',
				function($url) use ($path,$f3,$webBase,$basePath,$targetDir,$method) {
					// Ignore absolute URLs
					if (preg_match('/https?:/',$url[2]) ||
						!$rPath=realpath($path.$url[2]))
						return $url[0];
					if ($method=='relative') {
						// relative from new public file path
						$filePathFromBase=str_replace($basePath,'',$f3->fixslashes($rPath));
						$rel=$this->relPath($targetDir,$filePathFromBase);
						return '('.$url[1].$rel.(isset($url[4])?$url[4]:'').$url[1].')';
					} elseif ($method=='absolute') {
						// absolute to web root / base
						return '('.$url[1].preg_replace(
								'/'.preg_quote($basePath,'/').'(.+)/',
								'\1',$webBase.'/'.$f3->fixslashes($rPath).(isset($url[4])?$url[4]:'')
							).$url[1].')';
					}
					return $url[0];
				},$content);
		}
		return $content;
	}
596745
public static function appendUri()
    {
        $path = array();
        foreach (func_get_args() as $arg) {
            if ($arg !== null) {
                $path[] = $arg;
            }
        }

        if (count($path) > 1) {
            $last = count($path) - 1;
            $path[0] = rtrim($path[0], '/');
            $path[$last] = ltrim($path[$last], '/');
            for ($i = 1; $i < $last; ++$i) {
                $path[$i] = trim($path[$i], '/');
            }
        }
        return implode("/", $path);
    }
1143047
public function buildUrl()
    {
        $url = $this->getApiUrl();
        if ($endpoint = $this->getEndpoint()) {
            $url .= $endpoint;
        }
        if ($id = $this->getId()) {
            $url .= '/'.$id;
        }
        $parameters = [];
        if ($include = $this->getInclude()) {
            if (is_array($include)) {
                $include = implode(',', $include);
            }
            $parameters['include'] = $include;
        }
        if ($filters = $this->getFilters()) {
            if (!empty($filters)) {
                $parameters['filter'] = $filters;
            }
        }
        if ($pageSize = $this->getPageSize()) {
            if (!empty($pageSize)) {
                $parameters['page'] = ['size' => $pageSize];
            }
        }
        if ($sort = $this->getSort()) {
            if (!empty($sort)) {
                $parameters['sort'] = $sort;
            }
        }
        if ($parameters) {
            $url .= '?'.http_build_query($parameters);
        }
        return $url;
    }
719260
public function updateUrl()
    {
        // if slug is url
        if (is_slug_url($this->slug)) {
            $this->url = $this->slug;

            return $this;
        }

        $this->url = '';
        $this->generateCompleteUrl($this);
        $this->url = $this->url;

        if (strlen($this->slug) == 1) {
            $this->url = $this->slug;
        }
        else if (strlen($this->slug) > 1) {
            $this->url .= (is_slug_url($this->slug) ? "" : "/") . $this->slug;
        }

        return $this;
    }
308735
public function prepareLinks() {
		$this[ Argument::LINKS ] = $this->doReplacements( $this[ Argument::LINKS ] );

		return $this;
	}
400328
public function getChunkDirectory($absolutePath = false)
    {
        $paths = [];

        if ($absolutePath) {
            $paths[] = $this->chunkStorage()->getDiskPathPrefix();
        }

        $paths[] = $this->chunkStorage()->directory();

        return implode('', $paths);
    }