Fix route and redirect methods error when path not start with slash.
This commit is contained in:
parent
9a1e5a2379
commit
a10308a8f6
@ -100,7 +100,7 @@ class Router {
|
|||||||
*/
|
*/
|
||||||
public static function redirect(string $path): void
|
public static function redirect(string $path): void
|
||||||
{
|
{
|
||||||
header('Location: '.static::basePath().substr($path,1));
|
header('Location: '.static::basePath().ltrim($path, '/'));
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -156,7 +156,7 @@ class View extends Neuron {
|
|||||||
public function route(string $path = '/'): string
|
public function route(string $path = '/'): string
|
||||||
{
|
{
|
||||||
if (defined('SITE_URL') && !empty(SITE_URL))
|
if (defined('SITE_URL') && !empty(SITE_URL))
|
||||||
return SITE_URL.substr($path,1);
|
return SITE_URL.ltrim($path, '/');
|
||||||
|
|
||||||
return $path;
|
return $path;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user