Open nicojmb opened 2 weeks ago
I cannot reproduce bug
$ git diff tests/system/Router/RouterTest.php
diff --git a/tests/system/Router/RouterTest.php b/tests/system/Router/RouterTest.php
index bb5302e721..212294c3d2 100644
--- a/tests/system/Router/RouterTest.php
+++ b/tests/system/Router/RouterTest.php
@@ -716,6 +716,34 @@ final class RouterTest extends CIUnitTestCase
$this->assertSame('auth_post', $router->methodName());
}
+ public function testRouteEndSlash(): void
+ {
+ $this->collection->post('api/devices', 'Main::auth_post');
+ $this->collection->get('api/devices', 'Main::index');
+ $router = new Router($this->collection, $this->request);
+
+ $this->collection->setHTTPVerb(Method::POST);
+
+ $router->handle('api/devices');
+ $this->assertSame('\Main', $router->controllerName());
+ $this->assertSame('auth_post', $router->methodName());
+
+ $this->collection->setHTTPVerb(Method::GET);
+
+ $router->handle('api/devices');
+ $this->assertSame('\Main', $router->controllerName());
+ $this->assertSame('index', $router->methodName());
+
+ $this->collection->setHTTPVerb(Method::DELETE);
+
+ $router->handle('api/devices/');
+ $this->assertSame('\Main', $router->controllerName());
+ $this->assertSame('index', $router->methodName());
+ }
+
$ vendor/bin/phpunit tests/system/Router/RouterTest.php
PHPUnit 11.4.2 by Sebastian Bergmann and contributors.
Runtime: PHP 8.3.12 with Xdebug 3.3.2
Configuration: D:\Project\laragon\www\ci4\phpunit.xml.dist
........................................E................... 60 / 60 (100%)
Time: 00:01.434, Memory: 20.00 MB
There was 1 error:
1) CodeIgniter\Router\RouterTest::testMultipleThree
CodeIgniter\Exceptions\PageNotFoundException: Can't find a route for 'DELETE: api/devices/'.
D:\Project\laragon\www\ci4\system\Router\Router.php:222
D:\Project\laragon\www\ci4\tests\system\Router\RouterTest.php:742
ERRORS!
Tests: 60, Assertions: 161, Errors: 1, PHPUnit Deprecations: 1.
Generating code coverage report in Clover XML format ... done [00:00.923]
Generating code coverage report in HTML format ... done [00:07.057]
@nicojmb can you share configuration in app/Config/Routes
?
PHP Version
8.3
CodeIgniter4 Version
4.5.5
CodeIgniter4 Installation Method
Manual (zip or tar.gz)
Which operating systems have you tested for this bug?
Linux
Which server did you use?
fpm-fcgi
Database
MariaDB
What happened?
Hi, I've these routes:
In postman if i execute:
GET --> /api/devices --> Respond OK POST --> /api/devices --> Respond OK DELETE --> /api/devices --> Respond ERROR (it's normal not exists route)
but if i execute with and slash "/" at the end, all routes respond as if they were GET.
GET --> /api/devices/ --> Respond OK POST --> /api/devices/ --> Respond OK DELETE --> /api/devices/ --> Respond OK
and I can't find where the problem is
Steps to Reproduce
Make a postman call with adding a slash to the end
Expected Output
Same answer whether it has a slash or not
Anything else?
No response