From 1a86abeb2df95f98eefbe0ded6eeb754336e07ff Mon Sep 17 00:00:00 2001 From: Pablo Ferreiro Date: Tue, 29 Mar 2022 19:35:29 +0200 Subject: [PATCH] Small patch --- app/Helpers/Misc.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/Helpers/Misc.php b/app/Helpers/Misc.php index a223fcc..2619287 100644 --- a/app/Helpers/Misc.php +++ b/app/Helpers/Misc.php @@ -2,6 +2,10 @@ namespace App\Helpers; class Misc { + static private function isSecure() { + return (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') || $_SERVER['SERVER_PORT'] == 443; + } + static public function getCursor(): int { return isset($_GET['cursor']) && is_numeric($_GET['cursor']) ? (int) $_GET['cursor'] : 0; } @@ -11,7 +15,7 @@ class Misc { } static public function url(string $endpoint = ''): string { - $protocol = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http"; + $protocol = self::isSecure() ? 'https' : 'http'; $root = $protocol . '://' . $_SERVER['HTTP_HOST']; return $root . self::env('APP_PATH', '') . $endpoint; }