From 4fbb1ea607a233db891b147536d4d2aa649b2e44 Mon Sep 17 00:00:00 2001 From: Freya Murphy Date: Fri, 27 Feb 2026 09:33:49 -0500 Subject: add function to get http scheme --- src/_base.php | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'src/_base.php') diff --git a/src/_base.php b/src/_base.php index e029130..add20a8 100644 --- a/src/_base.php +++ b/src/_base.php @@ -180,6 +180,18 @@ abstract class Base { return 0; } + /** + * @returns the http scheme currently being used + */ + public static function get_scheme(): string + { + $scheme = 'http'; + if (isset($_SERVER['HTTP_X_FORWARDED_PROTO'])) + $scheme = $_SERVER['HTTP_X_FORWARDED_PROTO']; + + return $scheme; + } + /** * Gets a full path url from a relative path * @param string $path @@ -187,10 +199,7 @@ abstract class Base { */ public static function get_url(string $path, bool $timestamp = FALSE): string { - $scheme = 'http'; - if (isset($_SERVER['HTTP_X_FORWARDED_PROTO'])) - $scheme = $_SERVER['HTTP_X_FORWARDED_PROTO']; - + $scheme = self::get_scheme(); $host = $_SERVER['HTTP_HOST']; if (ENVIRONMENT == 'production') { -- cgit v1.2.3-freya