Skip to content

Commit f60db2c

Browse files
committed
fix: ran "php-cs-fixer fix" to make the SiteURIFactory follow the changes conform to style guide
1 parent 20607d8 commit f60db2c

File tree

1 file changed

+18
-14
lines changed

1 file changed

+18
-14
lines changed

system/HTTP/SiteURIFactory.php

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -111,32 +111,36 @@ public function detectRoutePath(string $protocol = ''): string
111111
*/
112112
private function parseRequestURI(): string
113113
{
114-
$appConfig = config(\Config\App::class);
115-
$baseUrl = $appConfig->baseURL;
114+
$appConfig = config(App::class);
115+
$baseUrl = $appConfig->baseURL;
116116
$indexPage = $appConfig->indexPage;
117-
$baseUri = false;
117+
$baseUri = false;
118118
$parsedUrl = parse_url($baseUrl);
119-
120-
if(isset($parsedUrl['path'])){ // The path could be empty if the url is just a domain
119+
120+
if (isset($parsedUrl['path'])) { // The path could be empty if the url is just a domain
121121
$baseUri = $parsedUrl['path'];
122122
}
123-
if($baseUri){
123+
if ($baseUri) {
124124
$baseUriArray = explode('/', $baseUri);
125125
$baseUriArray = array_filter($baseUriArray); // We remove the empty strings from the array
126-
$baseUri = implode('/', $baseUriArray); // We join the array back into a string with slashes
127-
if(strlen($baseUri) > 0){
128-
$baseUri = "/" . $baseUri; // We add a slash at the beginning of the base Uri as implode will not do that
129-
}else{
126+
$baseUri = implode('/', $baseUriArray); // We join the array back into a string with slashes
127+
if ($baseUri !== '') {
128+
$baseUri = '/' . $baseUri; // We add a slash at the beginning of the base Uri as implode will not do that
129+
} else {
130130
$baseUri = false;
131131
}
132132
}
133133

134134
$serverRequestUri = $this->superglobals->server('REQUEST_URI'); // We get the request URI from the server superglobals
135135

136-
if(!is_null($serverRequestUri)){
137-
if($baseUri && str_starts_with($serverRequestUri, $baseUri)) $serverRequestUri = substr($serverRequestUri, strlen($baseUri)); // We remove the base Uri from the request URI if it exists, baseUri is the path to the subdirectory
138-
if($indexPage != false && str_starts_with($serverRequestUri, "/" . $indexPage)) $serverRequestUri = substr($serverRequestUri, strlen("/" . $indexPage)); // We remove the index page from the request URI if it exists
139-
$serverRequestUri = "/". ltrim($serverRequestUri, '/'); // makes sure that the uri starts with a slash
136+
if (null !== $serverRequestUri) {
137+
if ($baseUri && str_starts_with($serverRequestUri, $baseUri)) {
138+
$serverRequestUri = substr($serverRequestUri, strlen($baseUri));
139+
} // We remove the base Uri from the request URI if it exists, baseUri is the path to the subdirectory
140+
if ($indexPage !== false && str_starts_with($serverRequestUri, '/' . $indexPage)) {
141+
$serverRequestUri = substr($serverRequestUri, strlen('/' . $indexPage));
142+
} // We remove the index page from the request URI if it exists
143+
$serverRequestUri = '/' . ltrim($serverRequestUri, '/'); // makes sure that the uri starts with a slash
140144
}
141145

142146
if (

0 commit comments

Comments
 (0)