OSDN Git Service
(root)
/
php-libraries
/
Router.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
ddac4ce
)
Refactor router to check currentDir before replace
author
Duyle Campos
<duylecampos@gmail.com>
Fri, 18 Sep 2015 23:34:34 +0000
(20:34 -0300)
committer
Duyle Campos
<duylecampos@gmail.com>
Fri, 18 Sep 2015 23:34:34 +0000
(20:34 -0300)
Check if currentDir not is / before replace in requesturl
closes github/issue 56
src/PHPRouter/Router.php
patch
|
blob
|
history
diff --git
a/src/PHPRouter/Router.php
b/src/PHPRouter/Router.php
index
e191a5d
..
595e434
100755
(executable)
--- a/
src/PHPRouter/Router.php
+++ b/
src/PHPRouter/Router.php
@@
-102,7
+102,9
@@
class Router
}
$currentDir = dirname($_SERVER['SCRIPT_NAME']);
- $requestUrl = str_replace($currentDir, '', $requestUrl);
+ if ($currentDir != '/') {
+ $requestUrl = str_replace($currentDir, '', $requestUrl);
+ }
// check if request _url matches route regex. if not, return false.
if (! preg_match("@^" . $this->basePath . $routes->getRegex() . "*$@i", $requestUrl, $matches)) {