diff options
| author | Freya Murphy <freya@freyacat.org> | 2026-02-27 09:33:49 -0500 |
|---|---|---|
| committer | Freya Murphy <freya@freyacat.org> | 2026-02-27 09:33:49 -0500 |
| commit | 4fbb1ea607a233db891b147536d4d2aa649b2e44 (patch) | |
| tree | bf8c457d6ded802469c7a91dbec5a5874de45fd8 | |
| parent | fix compose override path (diff) | |
| download | crimson-4fbb1ea607a233db891b147536d4d2aa649b2e44.tar.gz crimson-4fbb1ea607a233db891b147536d4d2aa649b2e44.tar.bz2 crimson-4fbb1ea607a233db891b147536d4d2aa649b2e44.zip | |
add function to get http scheme
Diffstat (limited to '')
| -rw-r--r-- | src/_base.php | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/_base.php b/src/_base.php index e029130..add20a8 100644 --- a/src/_base.php +++ b/src/_base.php @@ -181,16 +181,25 @@ abstract class Base { } /** + * @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 * @param bool $timestamp */ 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') { |