// empty URI
if (!
$uri) { return $baseUri;
} // an anchor
if ('#' ===
$uri[0
]) { return self::
cleanupAnchor($baseUri).
$uri;
} $baseUriCleaned = self::
cleanupUri($baseUri);
if ('?' ===
$uri[0
]) { return $baseUriCleaned.
$uri;
} // absolute URL with relative schema
if (str_starts_with($uri, '//'
)) { return preg_replace('#^([^/]*)//.*$#', '$1',
$baseUriCleaned).
$uri;
} $baseUriCleaned =
preg_replace('#^(.*?//[^/]*)(?:\/.*)?$#', '$1',
$baseUriCleaned);