Returns either the concatenated string or null on wrong params.

@param string $baseUrl
@param string $resource
@return string|null Null on invalid {$baseUrl}
17436
public function buildUrlString($baseUrl, $resource)
    {
        if (null === $baseUrl || '' == $baseUrl) {
            return null;
        }

        if (null === $resource || '' == $resource) {
            return $baseUrl;
        }

        $baseUrl = $this->removeTrainingSlash($baseUrl);
        if (!substr($resource, 0, 1) == '/') {
            $resource = '/' . $resource;
        }

        return $baseUrl . $resource;
    }
217596
public static function abs_url($url, $base)
    {
        if (!self::is_url_path($url)) {
            $t = is_array($base) ? $base : parse_url($base);
            if (strncmp($url, '//', 2) == 0) {
                if (!empty($t['scheme'])) {
                    $url = $t['scheme'] . ':' . $url;
                }
            } else {
                $base = (empty($t['scheme']) ? '//' : $t['scheme'] . '://') .
                    $t['host'] . (empty($t['port']) ? '' : ':' . $t['port']);
                if (!empty($t['path'])) {
                    $s = dirname($t['path'] . 'f');
                    if (DIRECTORY_SEPARATOR != '/') {
                        $s = strtr($s, DIRECTORY_SEPARATOR, '/');
                    }
                    if ($s && '.' !== $s && '/' !== $s && substr($url, 0, 1) !== '/') {
                        $base .= '/' . ltrim($s, '/');
                    }
                }
                $url = rtrim($base, '/') . '/' . ltrim($url, '/');
            }
        } else {
            $p = strpos($url, ':');
            if (substr($url, $p + 3, 1) === '/' && in_array(substr($url, 0, $p), array('http', 'https'))) {
                $url = substr($url, 0, $p + 3) . ltrim(substr($url, $p + 3), '/');
            }
        }
        return $url;
    }
497518
public static function create(string $baseUri, array $query = []): string
    {
        if (count($query) === 0) {
            return $baseUri;
        }

        return sprintf('%s/?%s', $baseUri, http_build_query($query));
    }
9492
public static String getBaseUrl(String url, Logger logger) {
    String answer = url;
    switch (identify(url)) {
      case COMPOSUM:
        answer = url.substring(0, url.indexOf(COMPOSUM_URL));
        break;
      case CRX:
        answer = url.substring(0, url.indexOf(CRX_URL));
        break;
      default:
        logger.error("Given URL is not supported: " + url);
    }
    return answer;
  }
300017
public function getURL(): ?string
    {
        if ($this->base !== null) {
            $list = [];
            $queryList = $this->query->getList();
            foreach ($queryList as $queryItem) {
                $list[$queryItem->name] = $queryItem->value;
            }
            return $this->base . implode('/', array_map('urlencode', explode('/', (string) $this->path))) . (empty($list) ? '' : '?' . http_build_query($list));
        }
        return null;
    }
1284355
public function buildBaseString($uri, array $parameters = [], $httpMethod = 'POST')
    {
        return $this->getBaseStringBuilder()->build($httpMethod, $uri, $parameters);
    }
546036
private static function fixVtigerBaseUrl($baseUrl)
    {
        if (!preg_match('/^https?:\/\//i', $baseUrl)) {
            $baseUrl = sprintf('http://%s', $baseUrl);
        }
        if (strripos($baseUrl, '/') !== strlen($baseUrl) - 1) {
            $baseUrl .= '/';
        }
        return $baseUrl;
    }
47596
public function parseUrl($url, $config = []) {
		foreach ($this->_hosts as $stub) {
			$match = $this->_matchUrl($url, (array)$stub['url-match']);
			if (!$match) {
				continue;
			}

			$this->_match = $match;

			if (!empty($stub['fetch-match'])) {
				if (!$this->_parseLink($url, $stub['fetch-match'])) {
					return null;
				}
			}

			$stub['match'] = $this->_match;
			$Object = $this->object($stub, $config + $this->config);
			return $Object;
		}
	}
980837
public static function getUrl($resource, $absolute = false) {
		if (strpos ( $resource, '//' ) !== false) {
			return $resource;
		}
		if ($absolute) {
			return self::$siteURL . self::ASSETS_FOLDER . $resource;
		}
		return ltrim ( self::ASSETS_FOLDER, '/' ) . $resource;
	}
753611
public static function toXml($resource, $root = 'root') {
        if ($resource instanceof Xmlable) {
            return $resource->toXml($root);

        } else if ($array = static::toArray($resource, true)) {
            $xml = simplexml_load_string('<?xml version="1.0" encoding="utf-8"?><' . $root . '></' . $root . '>');
            $response = static::buildXml($xml, $array);

            return trim($response->asXML());
        }

        return null;
    }
219570
final URI spliceUrl(String resource, Map<String, String> parameters) throws RestEndpointIOException {
        try {
            URIBuilder builder;
            if (!Strings.isNullOrEmpty(baseUrl)) {
                builder = new URIBuilder(baseUrl);
                builder.setPath(builder.getPath() + resource);
            } else {
                builder = new URIBuilder(resource);
            }
            for (Entry<String, String> parameter : parameters.entrySet()) {
                builder.addParameter(parameter.getKey(), parameter.getValue());
            }
            return builder.build();
        } catch (URISyntaxException e) {
            throw new RestEndpointIOException(
                    "Unable to builder URL with base url '" + baseUrl + "' and resouce '" + resource + "'", e);
        }
    }
105367
private function completePath(string $resource): string
    {
        if (substr($resource, 0, strlen((string) $this->rootpath)) == $this->rootpath) {
            return $resource;
        }

        return $this->rootpath
                . DIRECTORY_SEPARATOR . 'src'
                . DIRECTORY_SEPARATOR . 'main'
                . DIRECTORY_SEPARATOR . 'resources'
                . DIRECTORY_SEPARATOR . $resource;
    }
1341555
public function getWebPathForResource(Resource $resource)
    {
        $relPath = Path::makeRelative($resource->getRepositoryPath(), $this->basePath);

        return '/'.trim($this->mapping->getWebPath().'/'.$relPath, '/');
    }
217574
public function getServiceUrl($resource = '', $params = [])
    {
        $format = $resource === '' ? '' : '.json';
        $url = $this->serviceScheme . '://' . $this->serviceDomain . '/'
            . $resource . $format;

        if ($params) {
            $url .= '?' . http_build_query($params);
        }

        return $url;
    }
1165222
protected function transformUri($url, $baseUrl)
    {
        // Only relative URIs must be transformed while
        // taking xml:base into account.
        if (Url::isRelative($url) === false) {
            return $url;
        }

        $xmlBasePolicy = $this->getRenderingEngine()->getXmlBasePolicy();

        switch ($xmlBasePolicy) {

            case AbstractMarkupRenderingEngine::XMLBASE_PROCESS:
                if (empty($baseUrl) === false) {
                    return Url::rtrim($baseUrl) . '/' . Url::ltrim($url);
                } else {
                    return $url;
                }
            break;

            default:
                return $url;
            break;
        }
    }
1118955
public function uri($name, $baseUri = null)
    {

        if (empty($baseUri)) {
            $baseUri = $this->baseUri;
        }

        return $baseUri . $this->get($name);
    }
1225172
private static function getBaseUrl()
    {
        if (isset($_SERVER['SERVER_NAME'])) {
            $sProtocol = !empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS'])
                == 'on' ? 'https' : 'http';
            return $sProtocol.'://'.$_SERVER['SERVER_NAME'];
        }
        return null;
    }