Skip to content

Commit

Permalink
refactor: SiteURI::__construct()
Browse files Browse the repository at this point in the history
  • Loading branch information
kenjis committed Feb 20, 2023
1 parent 7eaeac2 commit d1c14c9
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions system/HTTP/SiteURI.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,24 +92,23 @@ public function __construct(
?string $host = null,
?string $scheme = null
) {
$baseURL = $this->normalizeBaseURL($configApp);
$this->indexPage = $configApp->indexPage;

$baseURL = $this->normalizeBaseURL($configApp);
$this->setBasePath($baseURL);

$relativePath = URI::removeDotSegments($relativePath);
// Remove starting slash
if ($relativePath !== '' && $relativePath[0] === '/') {
$relativePath = ltrim($relativePath, '/');
}

// Check for an index page
$indexPage = '';
if ($configApp->indexPage !== '') {
$indexPage = $configApp->indexPage;

// Check if we need a separator
if ($relativePath !== '' && $relativePath[0] !== '/' && $relativePath[0] !== '?') {
$indexPage .= '/';
}
$indexPage = $configApp->indexPage . '/';
}

$relativePath = URI::removeDotSegments($relativePath);

$tempUri = $baseURL . $indexPage . $relativePath;
$uri = new URI($tempUri);

Expand Down Expand Up @@ -254,7 +253,7 @@ public function __toString(): string
return static::createURIString(
$this->getScheme(),
$this->getAuthority(),
$this->getPath(), // Absolute URIs should use a "/" for an empty path
$this->getPath(),
$this->getQuery(),
$this->getFragment()
);
Expand Down

0 comments on commit d1c14c9

Please sign in to comment.