Returns the path to a principal's calendar home.

The return url must not end with a slash.
This function should return null in case a principal did not have
a calendar home.

@param string $principalUrl

@return string
192393
public function getCalendarHomeForPrincipal($principalUrl)
    {
        // The default behavior for most sabre/dav servers is that there is a
        // principals root node, which contains users directly under it.
        //
        // This function assumes that there are two components in a principal
        // path. If there's more, we don't return a calendar home. This
        // excludes things like the calendar-proxy-read principal (which it
        // should).
        $parts = explode('/', trim($principalUrl, '/'));
        if (2 !== count($parts)) {
            return;
        }
        if ('principals' !== $parts[0]) {
            return;
        }

        return self::CALENDAR_ROOT.'/'.$parts[1];
    }
1135998
protected function _url($url = null) {
		if ($url !== null) {
			return '/' . trim($url, '/');
		} elseif ($uri = $this->env('REQUEST_URI')) {
			list($uri) = explode('?', $uri, 2);
			$base = '/^' . preg_quote($this->_base, '/') . '/';
			return '/' . trim(preg_replace($base, '', $uri), '/') ?: '/';
		}
		return '/';
	}
1176993
protected function pathForFile($fileOrUrl)
    {
        // Since combined urls could be root relative, treat them as urls here.
        if (preg_match('{^(//)|(http[s]?:)}', $fileOrUrl) || Director::is_root_relative_url($fileOrUrl)) {
            return $fileOrUrl;
        } else {
            return Injector::inst()->get(ResourceURLGenerator::class)->urlForResource($fileOrUrl);
        }
    }
483794
public static function path()
    {
        $url = '';

        // Get the rest of the URL
        if (!Arr::key('REQUEST_URI', $_SERVER)) {
            // Microsoft IIS doesn't set REQUEST_URI by default
            if ($queryString = Arr::key('QUERY_STRING', $_SERVER, true)) {
                $url .= '?' . $queryString;
            }
        } else {
            $url .= $_SERVER['REQUEST_URI'];
        }

        return $url ?: null;
    }
1268282
public function url(): string
    {
        //find a module providing the place hierarchy
        $module = app(ModuleService::class)
            ->findByComponent(ModuleListInterface::class, $this->tree, Auth::user())
            ->first(static function (ModuleInterface $module): bool {
                return $module instanceof PlaceHierarchyListModule;
            });
        
        if ($module instanceof PlaceHierarchyListModule) {
            return $module->listUrl($this->tree, [
                'parent' => $this->parts->reverse()->all(),
                'ged'    => $this->tree->name(),
            ]);
        }

        // The place-list module is disabled...
        return '#';
    }
1082149
public static function segmentUrl($url = null)
    {
        if (!is_null($url) && !empty($url)) {
            $url = $url;
        } else {
            $url = self::requestInstance()->getRequestUrl();
        }

        return explode('/', trim($url, '/'));
    }
404007
public function findAsset($url)
    {
        if (empty($url)) {
            return false;
        }

        $this->asset = $this->processUrl($url);

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

        // check main assets dir
        $mainAsset = $this->findMainAsset(
            $this->docRoot . DS . $this->assetDir . DS . $this->asset['asset']
        );
        if ($mainAsset !== false) {
            return $mainAsset;
        }

        // check the set theme
        $themeAsset = $this->findThemeAsset(
            $this->asset['folder'],
            $this->assetDir . DS . $this->asset['asset']
        );
        if ($themeAsset !== false) {
            return $themeAsset;
        }

        // get the last "fallback" directory
        return $this->findFallbackAsset(
            $this->assetDir . DS . $this->asset['asset'],
            $this->Folder
        );
    }
1001236
public function getMainUrl($url)
    {
        $social  = $this->getSocialNetworkFromDomain($url);
        foreach ($this->getDefinitions() as $domain => $name) {

            if ($name == $social) {

                return $domain;
            }
        }
        return $url;
    }
81774
private function getUrl(string $url): string
    {
        $urlParts = parse_url($url);

        if ($urlParts === false) {
            throw new \ParseError("Could not parse URL: $url");
        }

        if ($this->baseUrl !== null && ! isset($urlParts['host'])) {
            $url = $this->baseUrl . '/' . ltrim($url, '/');
        }

        return $url;
    }
381863
protected function findProviderForUrl($url)
    {
        foreach ($this->providers as $provider) {
            if ($provider->match($url)) {
                return $provider;
            }
        }

        return null;
    }
865368
static public function getRootUrl($url=null)
	{
	    if (!$url || strpos($url, '://') === false) {
            $schema = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? 'https://' : 'http://';
            $domain = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : getenv('HTTP_HOST');
            $domain = static::GetRootDomain($domain);
            $baseUrl = $domain ? $schema . $domain : '';
            $port = isset($_SERVER['SERVER_PORT']) ? $_SERVER['SERVER_PORT'] : null;
	    } else {
	        $parts = parse_url($url);
	        $domain = static::GetRootDomain($parts['host']);
	        $baseUrl = $parts['scheme'] . '://' . $domain;
	        $port = isset($parts['port']) ? $parts['port'] : '';
	    }
	    if ($port && $port != 80 && $port != 443) {
	        $baseUrl .= ':'.$port;
	    }
	    
	    return $baseUrl;
	}
95470
public function getAddressBooksForUser($principalUri)
    {
        $stmt = $this->pdo->prepare('SELECT id, uri, displayname, principaluri, description, synctoken FROM '.$this->addressBooksTableName.' WHERE principaluri = ?');
        $stmt->execute([$principalUri]);

        $addressBooks = [];

        foreach ($stmt->fetchAll() as $row) {
            $addressBooks[] = [
                'id' => $row['id'],
                'uri' => $row['uri'],
                'principaluri' => $row['principaluri'],
                '{DAV:}displayname' => $row['displayname'],
                '{'.CardDAV\Plugin::NS_CARDDAV.'}addressbook-description' => $row['description'],
                '{http://calendarserver.org/ns/}getctag' => $row['synctoken'],
                '{http://sabredav.org/ns}sync-token' => $row['synctoken'] ? $row['synctoken'] : '0',
            ];
        }

        return $addressBooks;
    }
1135267
public function getCuztomUrl($path = __FILE__, $url = [])
    {
        // Retun URL if defined
        if (defined('CUZTOM_URL')) {
            return CUZTOM_URL;
        }

        // Base vars
        $path = dirname($path);
        $path = str_replace('\\', '/', $path);
        $expath = explode('/', $path);
        $current = $expath[count($expath) - 1];

        // Push to path array
        array_push($url, $current);

        // Check for current
        if (preg_match('/content|app/', $current)) {
            $path = '';
            $directories = array_reverse($url);

            foreach ($directories as $dir) {
                if (! preg_match('/content|app/', $dir)) {
                    $path = $path.'/'.$dir;
                }
            }

            return apply_filters('cuztom_url', WP_CONTENT_URL.$path);
        } else {
            return $this->getCuztomUrl($path, $url);
        }
    }
845645
public static function getPath($url)
    {
        $matchFound = preg_match('/(\/v[23]\/.*$)/', $url, $matches);
        if( ! $matchFound || ! is_array($matches) || ! isset($matches[1])) {
            throw new \Exception('Unable to parse url path', 1462733286);
        }

        return $matches[1];
    }
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;
	}
215761
protected function pathFromParsedUrl($parsedUrl)
    {
        $path = '/' . implode('/', $parsedUrl['segments']);
        if ($parsedUrl['query']) {
            $path .= "?{$parsedUrl['query']}";
        }
        if ($parsedUrl['fragment']) {
            $path .= "#{$parsedUrl['fragment']}";
        }
        return $path;
    }
424505
private function generateUrl($url)
    {
        if ($this->packages) {
            return $this->packages->getUrl($url);
        }

        if ($this->coreAssetsHelper) {
            // To remove when compatibility with Symfony 2.7 is dropped
            return $this->coreAssetsHelper->getUrl($url);
        }

        return $url;
    }