You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: system/HTTP/SiteURIFactory.php
+18-14Lines changed: 18 additions & 14 deletions
Original file line number
Diff line number
Diff line change
@@ -111,32 +111,36 @@ public function detectRoutePath(string $protocol = ''): string
111
111
*/
112
112
privatefunctionparseRequestURI(): string
113
113
{
114
-
$appConfig = config(\Config\App::class);
115
-
$baseUrl = $appConfig->baseURL;
114
+
$appConfig = config(App::class);
115
+
$baseUrl= $appConfig->baseURL;
116
116
$indexPage = $appConfig->indexPage;
117
-
$baseUri = false;
117
+
$baseUri= false;
118
118
$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
121
121
$baseUri = $parsedUrl['path'];
122
122
}
123
-
if($baseUri){
123
+
if($baseUri){
124
124
$baseUriArray = explode('/', $baseUri);
125
125
$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{
130
130
$baseUri = false;
131
131
}
132
132
}
133
133
134
134
$serverRequestUri = $this->superglobals->server('REQUEST_URI'); // We get the request URI from the server superglobals
135
135
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)) {
0 commit comments