Skip to content

Commit

Permalink
Fixes path detection when running in subdirectories
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiopvilar committed Oct 6, 2016
1 parent b0aaac4 commit 5184273
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
"twig/twig": "~1.0",
"slim/slim": "~2.0",
"aura/session": "~2.0",
"nikic/fast-route": "^0.7.0"
"nikic/fast-route": "^0.7.0",
"symfony/http-foundation": "^3.1"
},
"require-dev": {
"phpunit/phpunit": "3.x"
Expand Down
3 changes: 2 additions & 1 deletion src/Route.php
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ public function parse_request() {

$self = $this;

$request = \Symfony\Component\HttpFoundation\Request::createFromGlobals();
$dispatcher = \FastRoute\simpleDispatcher(function($r) use ($self) {
foreach($self->routes as $route) {
$r->addRoute($route['methods'], $route['route'], $route['callback'], $route['id']);
Expand All @@ -256,7 +257,7 @@ public function parse_request() {

// Fetch method and URI from somewhere
$httpMethod = $_SERVER['REQUEST_METHOD'];
$uri = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
$uri = $request->getPathInfo();

if(strpos($uri, '/wp-admin') > -1) return;

Expand Down

0 comments on commit 5184273

Please sign in to comment.