Browse Source

Fix router base handling

Nathaniel van Diepen 8 years ago
parent
commit
628978eb43
1 changed files with 4 additions and 4 deletions
  1. 4 4
      App/router.class.php

+ 4 - 4
App/router.class.php

@@ -165,10 +165,10 @@
 			return $this;
 		}
 		public function handle(string $path, Request $req = null, Response $res = null, callable $fn = null, callable $onerror = null){
-			if(strpos($path, $this->base) !== false){
-				$path = ltrim($path, $this->base);
-				if($path[0] != '/'){
-					$path = '/'.$path;
+			if(strpos($path, $this->base) === 0){
+				$path = substr($path, strlen($this->base));
+				if(strpos($path, '/') !== 0){
+					$path = "/{$path}";
 				}
 				if(is_null($req)){
 					$req = new Request(Request::get_verb(), Request::get_url(), Request::get_headers(), Request::get_body());