Skip to content

Commit

Permalink
feat. check if server vars are set, breaks unit tests otherwise
Browse files Browse the repository at this point in the history
  • Loading branch information
Blackbam committed Mar 30, 2023
1 parent 7f6aaa3 commit fff2d3c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Url.php
Expand Up @@ -53,7 +53,7 @@ public static function getCanonical(): string
#[Pure]
public static function getCurrent(): string
{
return self::getHostUrl() . $_SERVER['REQUEST_URI'];
return self::getHostUrl() . ($_SERVER['REQUEST_URI'] ?? "");
}

/**
Expand All @@ -62,7 +62,7 @@ public static function getCurrent(): string
#[Pure]
public static function getHostUrl(): string
{
return "http" . (self::isSecure() ? "s" : "") . "://" . $_SERVER['HTTP_HOST'];
return "http" . (self::isSecure() ? "s" : "") . "://" . ($_SERVER['HTTP_HOST'] ?? "");
}

/**
Expand All @@ -72,7 +72,7 @@ public static function getHostUrl(): string
*/
public static function isSecure(): bool
{
return (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') || $_SERVER['SERVER_PORT'] === 443;
return (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') || (isset($_SERVER["SERVER_PORT"]) && $_SERVER['SERVER_PORT'] === 443);
}

/**
Expand Down

0 comments on commit fff2d3c

Please sign in to comment.