Skip to content

Commit 07611b4

Browse files
committed
Skip wildcard conversion when all origin is allowed
1 parent eff8fdb commit 07611b4

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/CorsService.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -105,13 +105,6 @@ private function validateOptions(): void
105105

106106
private function normalizeOptions(): void
107107
{
108-
// Transform wildcard pattern
109-
foreach ($this->allowedOrigins as $origin) {
110-
if (strpos($origin, '*') !== false) {
111-
$this->allowedOriginsPatterns[] = $this->convertWildcardToPattern($origin);
112-
}
113-
}
114-
115108
// Normalize case
116109
$this->allowedHeaders = array_map('strtolower', $this->allowedHeaders);
117110
$this->allowedMethods = array_map('strtoupper', $this->allowedMethods);
@@ -120,6 +113,15 @@ private function normalizeOptions(): void
120113
$this->allowAllOrigins = in_array('*', $this->allowedOrigins);
121114
$this->allowAllHeaders = in_array('*', $this->allowedHeaders);
122115
$this->allowAllMethods = in_array('*', $this->allowedMethods);
116+
117+
// Transform wildcard pattern
118+
if (!$this->allowAllOrigins) {
119+
foreach ($this->allowedOrigins as $origin) {
120+
if (strpos($origin, '*') !== false) {
121+
$this->allowedOriginsPatterns[] = $this->convertWildcardToPattern($origin);
122+
}
123+
}
124+
}
123125
}
124126

125127
/**

0 commit comments

Comments
 (0)