mirror of
https://github.com/dannyvankooten/AltoRouter.git
synced 2025-08-04 07:27:36 +02:00
@@ -25,10 +25,6 @@ class AltoRouter {
|
|||||||
*/
|
*/
|
||||||
public function map($method, $route, $target, $name = null) {
|
public function map($method, $route, $target, $name = null) {
|
||||||
|
|
||||||
if($route != '*') {
|
|
||||||
$route = $this->basePath . $route;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->routes[] = array($method, $route, $target, $name);
|
$this->routes[] = array($method, $route, $target, $name);
|
||||||
|
|
||||||
if($name) {
|
if($name) {
|
||||||
@@ -61,7 +57,9 @@ class AltoRouter {
|
|||||||
|
|
||||||
// Replace named parameters
|
// Replace named parameters
|
||||||
$route = $this->namedRoutes[$routeName];
|
$route = $this->namedRoutes[$routeName];
|
||||||
$url = $route;
|
|
||||||
|
// prepend base path to route url again
|
||||||
|
$url = $this->basePath . $route;
|
||||||
|
|
||||||
if (preg_match_all('`(/|\.|)\[([^:\]]*+)(?::([^:\]]*+))?\](\?|)`', $route, $matches, PREG_SET_ORDER)) {
|
if (preg_match_all('`(/|\.|)\[([^:\]]*+)(?::([^:\]]*+))?\](\?|)`', $route, $matches, PREG_SET_ORDER)) {
|
||||||
|
|
||||||
@@ -101,6 +99,9 @@ class AltoRouter {
|
|||||||
$requestUrl = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '/';
|
$requestUrl = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '/';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// strip base path from request url
|
||||||
|
$requestUrl = substr($requestUrl, strlen($this->basePath));
|
||||||
|
|
||||||
// Strip query string (?a=b) from Request Url
|
// Strip query string (?a=b) from Request Url
|
||||||
if (($strpos = strpos($requestUrl, '?')) !== false) {
|
if (($strpos = strpos($requestUrl, '?')) !== false) {
|
||||||
$requestUrl = substr($requestUrl, 0, $strpos);
|
$requestUrl = substr($requestUrl, 0, $strpos);
|
||||||
|
Reference in New Issue
Block a user