Bugfix: Setup with subfolder works fine but doesn't match base path #23
This commit is contained in:
parent
48fa409e7f
commit
26e048cc88
|
@ -31,18 +31,31 @@ class Route {
|
||||||
self::$methodNotAllowed = $function;
|
self::$methodNotAllowed = $function;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function run($basepath = '/', $case_matters = false, $trailing_slash_matters = false, $multimatch = false) {
|
public static function run($basepath = '', $case_matters = false, $trailing_slash_matters = false, $multimatch = false) {
|
||||||
|
|
||||||
|
// The basepath never needs a trailing slash
|
||||||
|
// Because the trailing slash will be added using the route expressions
|
||||||
|
$basepath = rtrim($basepath, '/');
|
||||||
|
|
||||||
// Parse current URL
|
// Parse current URL
|
||||||
$parsed_url = parse_url($_SERVER['REQUEST_URI']);
|
$parsed_url = parse_url($_SERVER['REQUEST_URI']);
|
||||||
|
|
||||||
if (isset($parsed_url['path']) && $parsed_url['path'] != '/') {
|
$path = '/';
|
||||||
|
|
||||||
|
// If there is a path available
|
||||||
|
if (isset($parsed_url['path'])) {
|
||||||
|
// If the trailing slash matters
|
||||||
if ($trailing_slash_matters) {
|
if ($trailing_slash_matters) {
|
||||||
$path = $parsed_url['path'];
|
$path = $parsed_url['path'];
|
||||||
} else {
|
} else {
|
||||||
|
// If the path is not equal to the base path (including a trailing slash)
|
||||||
|
if($basepath.'/'!=$parsed_url['path']) {
|
||||||
|
// Cut the trailing slash away because it does not matters
|
||||||
$path = rtrim($parsed_url['path'], '/');
|
$path = rtrim($parsed_url['path'], '/');
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
$path = '/';
|
$path = $parsed_url['path'];
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get current request method
|
// Get current request method
|
||||||
|
|
Loading…
Reference in New Issue
Block a user