Skip to content

Commit acd810b

Browse files
committed
make basePath more consistent
1 parent ac3b7da commit acd810b

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/Tqdev/PhpCrudApi/Middleware/Router/SimpleRouter.php

+3-4
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class SimpleRouter implements Router
2626

2727
public function __construct(string $basePath, Responder $responder, Cache $cache, int $ttl, bool $debug)
2828
{
29-
$this->basePath = $this->detectBasePath($basePath);
29+
$this->basePath = rtrim($this->detectBasePath($basePath), '/');
3030
$this->responder = $responder;
3131
$this->cache = $cache;
3232
$this->ttl = $ttl;
@@ -111,9 +111,8 @@ private function getRouteNumbers(ServerRequestInterface $request): array
111111
private function removeBasePath(ServerRequestInterface $request): ServerRequestInterface
112112
{
113113
$path = $request->getUri()->getPath();
114-
$basePath = rtrim($this->basePath, '/');
115-
if (substr($path, 0, strlen($basePath)) == $basePath) {
116-
$path = substr($path, strlen($basePath));
114+
if (substr($path, 0, strlen($this->basePath)) == $this->basePath) {
115+
$path = substr($path, strlen($this->basePath));
117116
$request = $request->withUri($request->getUri()->withPath($path));
118117
}
119118
return $request;

0 commit comments

Comments
 (0)