- UrlExtension now supports multiple application URL

This commit is contained in:
Dave M. 2023-05-31 18:29:36 +00:00
parent 3dce6a41cb
commit 215bc26981
1 changed files with 14 additions and 3 deletions

View File

@ -17,7 +17,7 @@ PATTERN;
protected string $urlBase;
protected string $appUrl;
protected array $appUrl;
protected string $assetToken;
@ -32,7 +32,7 @@ PATTERN;
#[\Deprecated]
protected bool $enforceExistingArguments = true;
public function __construct(string $urlBase = "", string $assetToken = "", string $appUrl = "", bool $forceSSL = false) {
public function __construct(string $urlBase = "", string $assetToken = "", array $appUrl = [], bool $forceSSL = false) {
$this->urlBase = trim($urlBase, "/");
$this->assetToken = $assetToken;
$this->appUrl = $appUrl;
@ -202,7 +202,18 @@ PATTERN;
$port = $this->isDefaultPort() ? "" : ":" . $_SERVER['SERVER_PORT'];
}
return strtolower($this->appUrl ? $this->appUrl . $port : $_SERVER['HTTP_HOST']);
return strtolower($this->appUrl($port) ?: $_SERVER['HTTP_HOST']);
}
protected function appUrl(string $port) : string
{
$domain = strtolower($_SERVER['HTTP_HOST']);
if (in_array($domain, $this->appUrl)) {
return $domain . $port;
}
return $this->appUrl[0] . $port;
}
protected function isDefaultPort() : bool