From 288add48d5792567d5fbf55980b822db862f8faa Mon Sep 17 00:00:00 2001 From: Pablo Ferreiro Date: Thu, 21 Apr 2022 19:59:55 +0200 Subject: [PATCH] Redirect: Remove @ or # if sent accidentally --- app/Controllers/RedirectController.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/app/Controllers/RedirectController.php b/app/Controllers/RedirectController.php index 0f54fc1..2d0f8f0 100644 --- a/app/Controllers/RedirectController.php +++ b/app/Controllers/RedirectController.php @@ -9,12 +9,20 @@ class RedirectController { static public function redirect() { $endpoint = '/'; if (isset($_GET['type'], $_GET['term'])) { - $term = $_GET['term']; + $term = trim($_GET['term']); switch ($_GET['type']) { case 'user': + // Remove @ if sent + if ($term[0] === '@') { + $term = substr($term, 1); + } $endpoint = '/@' . $term; break; case 'tag': + // Remove # if sent + if ($term[0] === '#') { + $term = substr($term, 1); + } $endpoint = '/tag/' . $term; break; case 'music':