From f4da4401ef63ced2aee5525e9e8c4dd9f86095dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20DANIEL?= Date: Fri, 12 May 2023 15:17:37 +0200 Subject: [PATCH] [BUGFIX] Do not boot Slim if route prefix not exactly matched If the route prefix is `/api`, Slim must not boot for an url like `/api-external`. In order to fix that, the route prefix is know matched like `/api/`. The only downside is that `/api` (without trailing slash) is not handled by Slim anymore. --- src/Middleware/SlimInitiator.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Middleware/SlimInitiator.php b/src/Middleware/SlimInitiator.php index e0811ae..d6f6091 100644 --- a/src/Middleware/SlimInitiator.php +++ b/src/Middleware/SlimInitiator.php @@ -63,7 +63,7 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface } $prefix = $config['route'] ?? '/'; - if (strpos($request->getUri()->getPath(), $prefix) !== 0) { + if (strpos($request->getUri()->getPath(), rtrim($prefix, '/') . '/') !== 0) { continue; }