From 5ea19da4a301e495b313f3025fd25c5b81e0806e Mon Sep 17 00:00:00 2001 From: Daniel Love Date: Wed, 30 Mar 2022 09:13:52 -0600 Subject: [PATCH] Updating getSettings method to properly construct trusted host patterns for default site. --- src/Dotenv.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/Dotenv.php b/src/Dotenv.php index 2c1aab3..70b667a 100644 --- a/src/Dotenv.php +++ b/src/Dotenv.php @@ -303,16 +303,19 @@ public function getSettings(): array } else { foreach ($this->getDomains() as $domain) { - if (!$this->isMultiSite() || $this->isMultiSiteDefaultSiteAllowed()) { - $settings['trusted_host_patterns'][] = '^' . str_replace('.', '\.', $domain) . '$'; + if (! $this->isMultiSite() || $this->isMultiSiteDefaultSiteAllowed()) { + $settings['trusted_host_patterns'][] = '^' . \str_replace('.', '\.', $domain) . '$'; + $settings['trusted_host_patterns'][] = '^www\.' . \str_replace('.', '\.', $domain) . '$'; } + foreach ($this->getSites() as $site) { - if ($site === 'default' && !$this->isMultiSiteDefaultSiteAllowed()) { + if ($site === 'default') { continue; } + $settings['trusted_host_patterns'][] = \vsprintf('^%s\.%s$', [ - $site === 'default' ? 'www' : $site, - str_replace('.', '\.', $domain), + $site, + \str_replace('.', '\.', $domain), ]); } }