diff --git a/src/Core/Escape.php b/src/Core/Escape.php index 0c2a1e3..edb139e 100644 --- a/src/Core/Escape.php +++ b/src/Core/Escape.php @@ -48,14 +48,9 @@ public static function randomString(int $length = 8): string * @param string $link * @return string */ - public static function addSlaches(string $link): string + public static function addSlashes(string $link): string { - $sub_string = substr($link, 0, 1); - $new_link = substr($link, 1); - if ($sub_string == '/') { - $link = substr(self::addSlaches($new_link), 1); - } - return $link == '' ? $link : '/' . $link; + return "/" . trim($link,"/"); } /** diff --git a/src/Core/Http/Redirect.php b/src/Core/Http/Redirect.php index da66065..6c92bda 100644 --- a/src/Core/Http/Redirect.php +++ b/src/Core/Http/Redirect.php @@ -30,7 +30,7 @@ static function to($location = null) exit(); } else { $webroot = substr(WEB_ROOT, 0, -1); - $link = Escape::addSlaches($location); + $link = Escape::addSlashes($location); $location = $link == '' ? WEB_ROOT : $webroot . $link; header('Location:' . $location); exit();