From 153a17493002d4a0ba773ad24502bee6a8d14fd3 Mon Sep 17 00:00:00 2001 From: Bartek Fabiszewski Date: Tue, 30 Jan 2018 13:50:40 +0100 Subject: [PATCH] Fix double slash in URL, closes #50 --- helpers/auth.php | 3 ++- helpers/utils.php | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/helpers/auth.php b/helpers/auth.php index 2f6aea8..a582ba6 100644 --- a/helpers/auth.php +++ b/helpers/auth.php @@ -177,7 +177,8 @@ * @return void */ public function exitWithRedirect($path = "") { - header("Location: " . BASE_URL . $path); + $location = str_replace("//", "/", BASE_URL . $path); + header("Location: $location"); exit(); } } \ No newline at end of file diff --git a/helpers/utils.php b/helpers/utils.php index 82aabb4..ea13ced 100644 --- a/helpers/utils.php +++ b/helpers/utils.php @@ -108,6 +108,11 @@ exit; } + /** + * Calculate app base URL + * + * @return string URL + */ public static function getBaseUrl() { $proto = (!isset($_SERVER["HTTPS"]) || $_SERVER["HTTPS"] == "" || $_SERVER["HTTPS"] == "off") ? "http://" : "https://"; $host = isset($_SERVER["HTTP_HOST"]) ? $_SERVER["HTTP_HOST"] : "";