From 040d8ed6c2db9989efe4259772db50e169045b9e Mon Sep 17 00:00:00 2001 From: bim-g Date: Mon, 2 Sep 2024 03:15:24 +0200 Subject: [PATCH] [UPD] rename addslaches to addSlashes --- src/Core/Escape.php | 9 ++------- src/Core/Http/Redirect.php | 2 +- 2 files changed, 3 insertions(+), 8 deletions(-) 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();