Skip to content

Commit 2fa8fd5

Browse files
committed
Fixed issue related with regex for running path.
1 parent d2c1002 commit 2fa8fd5

File tree

7 files changed

+10
-18
lines changed

7 files changed

+10
-18
lines changed

src/Router.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class Router
4040
/**
4141
* Router Version
4242
*/
43-
const VERSION = '2.4.0';
43+
const VERSION = '2.4.1';
4444

4545
/**
4646
* @var string $baseFolder Pattern definitions for parameters of Route
@@ -790,8 +790,10 @@ protected function getRequestUri(): string
790790
$dirname = dirname($script);
791791
$dirname = $dirname === '/' ? '' : $dirname;
792792
$basename = basename($script);
793+
793794
$uri = str_replace([$dirname, $basename], '', $this->request()->server->get('REQUEST_URI'));
794-
$uri = preg_replace('/\/'.str_replace(['.'],['\.'], $this->baseFolder).'/', '', $uri, 1);
795+
$uri = preg_replace('/'.str_replace(['\\', '/', '.',], ['/', '\/', '\.'], $this->baseFolder).'/', '', $uri, 1);
796+
795797
return $this->clearRouteName(explode('?', $uri)[0]);
796798
}
797799
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
RewriteEngine On
2-
RewriteBase /tests/fixtures
2+
RewriteBase /tests
33
RewriteCond %{REQUEST_FILENAME} !-f
44
RewriteCond %{REQUEST_FILENAME} !-d
55
RewriteRule ^ index.php [QSA,L]

tests/fixtures/index.php renamed to tests/example/index.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,20 @@
22

33
require __DIR__ . '/../../vendor/autoload.php';
44

5-
use Buki\Router;
6-
75
$params = [
86
'paths' => [
9-
'controllers' => 'controllers/',
7+
'Controllers' => 'Controllers',
8+
'middlewares' => 'Middlewares',
109
],
1110
'namespaces' => [
12-
'controllers' => 'Controllers\\',
11+
'Controllers' => 'Controllers\\',
12+
'middlewares' => 'Middlewares\\',
1313
],
1414
'base_folder' => __DIR__,
1515
'main_method' => 'main',
1616
];
1717

18-
$router = new Router($params);
18+
$router = new \Buki\Router\Router($params);
1919

2020
$router->get('/', function() {
2121
return 'Hello World!';

tests/fixtures/travis-ci-apache renamed to tests/example/travis-ci-apache

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
Action php-fcgi /php-fcgi
1414
Alias /php-fcgi /usr/lib/cgi-bin/php-fcgi
1515
FastCgiExternalServer /usr/lib/cgi-bin/php-fcgi -host 127.0.0.1:9000 -pass-header Authorization
16-
1716
<Directory /usr/lib/cgi-bin>
1817
Require all granted
1918
</Directory>
File renamed without changes.

tests/fixtures/TestController.php

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)