Skip to content

Commit 40089f7

Browse files
committed
fix url path
1 parent 2c70bf6 commit 40089f7

2 files changed

Lines changed: 7 additions & 5 deletions

File tree

src/Http/Request.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ public function path(): string
193193
*/
194194
public function decodedPath(): string
195195
{
196-
return rawurldecode($this->path());
196+
return rawurldecode(trim($this->path(), '/'));
197197
}
198198

199199
/**

src/Http/ServerRequest.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -238,16 +238,18 @@ protected function _setConfig(array $config): void
238238
} elseif ($config['url'] !== '') {
239239
$config = $this->processUrlOption($config);
240240
$uri = new Uri(implode('?', [$config['url'], $config['environment']['QUERY_STRING'] ?? '']));
241-
} elseif (isset($config['environment']['REQUEST_URI'])) {
242-
$uri = new Uri($config['environment']['REQUEST_URI']);
243241
} else {
244-
$uri = Psr7ServerRequest::getUriFromGlobals();
242+
$uri = new Uri(Psr7ServerRequest::getUriFromGlobals()->__toString());
243+
}
244+
245+
if (isset($config['environment']['REQUEST_URI'])) {
246+
$uri = $uri->withPath($config['environment']['REQUEST_URI']);
245247
}
246248

247249
if (in_array($uri->getHost(), ['localhost', '127.0.0.1'], true)) {
248250
$uri = $uri->withHost(parse_url(config('app.base_url'), PHP_URL_HOST));
249251
}
250-
252+
251253
$this->_environment = $config['environment'];
252254

253255
$this->uri = $uri;

0 commit comments

Comments
 (0)