Skip to content

Commit fd5e4a6

Browse files
author
Designcise
committed
Fixed RequestTrait::getNormalizedUriPath() method to replace document root only once
1 parent f2beee4 commit fd5e4a6

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "designcise/bitframe-fastroute",
3-
"version": "1.0.2",
3+
"version": "1.0.3",
44
"type": "library",
55
"description": "FastRoute router middleware for BitFrame microframework",
66
"license": "MIT",

src/FastRouteRouter.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,10 @@ public function process(
7777
// folder containing the main 'index.php' file the root, which is the expected
7878
// behavior
7979
if (($index = strpos($_SERVER['PHP_SELF'], '/index.php')) !== false && $index > 0) {
80-
$script_url = strtolower(substr($_SERVER['PHP_SELF'], 0, $index));
81-
$reqUriPath = '/' . trim(str_replace(['/index.php', $script_url], '', $reqUriPath), '/');
80+
$scriptUrl = strtolower(substr($_SERVER['PHP_SELF'], 0, $index));
81+
$reqUriPath = '/' . trim(
82+
preg_replace(['/\/index\.php/', '/' . preg_quote($scriptUrl, '/') . '/'], '', $reqUriPath, 1), '/'
83+
);
8284
}
8385

8486
// dispatch request; returns:

0 commit comments

Comments
 (0)