Skip to content

Commit

Permalink
Fixed issue related with regex for running path.
Browse files Browse the repository at this point in the history
  • Loading branch information
izniburak committed Jan 21, 2022
1 parent d2c1002 commit 2fa8fd5
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 18 deletions.
6 changes: 4 additions & 2 deletions src/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class Router
/**
* Router Version
*/
const VERSION = '2.4.0';
const VERSION = '2.4.1';

/**
* @var string $baseFolder Pattern definitions for parameters of Route
Expand Down Expand Up @@ -790,8 +790,10 @@ protected function getRequestUri(): string
$dirname = dirname($script);
$dirname = $dirname === '/' ? '' : $dirname;
$basename = basename($script);

$uri = str_replace([$dirname, $basename], '', $this->request()->server->get('REQUEST_URI'));
$uri = preg_replace('/\/'.str_replace(['.'],['\.'], $this->baseFolder).'/', '', $uri, 1);
$uri = preg_replace('/'.str_replace(['\\', '/', '.',], ['/', '\/', '\.'], $this->baseFolder).'/', '', $uri, 1);

return $this->clearRouteName(explode('?', $uri)[0]);
}
}
2 changes: 1 addition & 1 deletion tests/fixtures/.htaccess → tests/example/.htaccess
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
RewriteEngine On
RewriteBase /tests/fixtures
RewriteBase /tests
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [QSA,L]
10 changes: 5 additions & 5 deletions tests/fixtures/index.php → tests/example/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@

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

use Buki\Router;

$params = [
'paths' => [
'controllers' => 'controllers/',
'Controllers' => 'Controllers',
'middlewares' => 'Middlewares',
],
'namespaces' => [
'controllers' => 'Controllers\\',
'Controllers' => 'Controllers\\',
'middlewares' => 'Middlewares\\',
],
'base_folder' => __DIR__,
'main_method' => 'main',
];

$router = new Router($params);
$router = new \Buki\Router\Router($params);

$router->get('/', function() {
return 'Hello World!';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
Action php-fcgi /php-fcgi
Alias /php-fcgi /usr/lib/cgi-bin/php-fcgi
FastCgiExternalServer /usr/lib/cgi-bin/php-fcgi -host 127.0.0.1:9000 -pass-header Authorization

<Directory /usr/lib/cgi-bin>
Require all granted
</Directory>
Expand Down
File renamed without changes.
9 changes: 0 additions & 9 deletions tests/fixtures/TestController.php

This file was deleted.

0 comments on commit 2fa8fd5

Please sign in to comment.