Skip to content

Commit

Permalink
Updating getSettings method to properly construct trusted host patter…
Browse files Browse the repository at this point in the history
…ns for default site.
  • Loading branch information
dl-unleashed-technologies committed Mar 30, 2022
1 parent 7438cb1 commit 5ea19da
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/Dotenv.php
Original file line number Diff line number Diff line change
Expand Up @@ -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),
]);
}
}
Expand Down

0 comments on commit 5ea19da

Please sign in to comment.