@@ -77,7 +77,7 @@ public class CorsConfiguration {
77
77
private List <String > allowedOrigins ;
78
78
79
79
@ Nullable
80
- private List <Pattern > allowedOriginsPatterns ;
80
+ private List <Pattern > allowedOriginPatterns ;
81
81
82
82
@ Nullable
83
83
private List <String > allowedMethods ;
@@ -112,7 +112,7 @@ public CorsConfiguration() {
112
112
*/
113
113
public CorsConfiguration (CorsConfiguration other ) {
114
114
this .allowedOrigins = other .allowedOrigins ;
115
- this .allowedOriginsPatterns = other .allowedOriginsPatterns ;
115
+ this .allowedOriginPatterns = other .allowedOriginPatterns ;
116
116
this .allowedMethods = other .allowedMethods ;
117
117
this .resolvedMethods = other .resolvedMethods ;
118
118
this .allowedHeaders = other .allowedHeaders ;
@@ -158,14 +158,14 @@ else if (this.allowedOrigins == DEFAULT_PERMIT_ALL) {
158
158
* Set the origins patterns to allow, e.g. {@code "*.com"}.
159
159
* <p>By default this is not set.
160
160
*/
161
- public CorsConfiguration setAllowedOriginsPatterns (@ Nullable List <String > allowedOriginsPatterns ) {
162
- if (allowedOriginsPatterns == null ) {
163
- this .allowedOriginsPatterns = null ;
161
+ public CorsConfiguration setAllowedOriginPatterns (@ Nullable List <String > allowedOriginPatterns ) {
162
+ if (allowedOriginPatterns == null ) {
163
+ this .allowedOriginPatterns = null ;
164
164
}
165
165
else {
166
- this .allowedOriginsPatterns = new ArrayList <>(allowedOriginsPatterns .size ());
167
- for (String pattern : allowedOriginsPatterns ) {
168
- this .allowedOriginsPatterns .add (Pattern .compile (pattern ));
166
+ this .allowedOriginPatterns = new ArrayList <>(allowedOriginPatterns .size ());
167
+ for (String pattern : allowedOriginPatterns ) {
168
+ this .allowedOriginPatterns .add (Pattern .compile (pattern ));
169
169
}
170
170
}
171
171
@@ -176,30 +176,30 @@ public CorsConfiguration setAllowedOriginsPatterns(@Nullable List<String> allowe
176
176
* Return the configured origins patterns to allow, or {@code null} if none.
177
177
*
178
178
* @see #addAllowedOriginPattern(String)
179
- * @see #setAllowedOriginsPatterns (List)
179
+ * @see #setAllowedOriginPatterns (List)
180
180
*/
181
181
@ Nullable
182
- public List <String > getAllowedOriginsPatterns () {
183
- if (this .allowedOriginsPatterns == null ) {
182
+ public List <String > getAllowedOriginPatterns () {
183
+ if (this .allowedOriginPatterns == null ) {
184
184
return null ;
185
185
}
186
- if (this .allowedOriginsPatterns == DEFAULT_PERMIT_ALL_PATTERN ) {
186
+ if (this .allowedOriginPatterns == DEFAULT_PERMIT_ALL_PATTERN ) {
187
187
return DEFAULT_PERMIT_ALL_PATTERN_STR ;
188
188
}
189
- return this .allowedOriginsPatterns .stream ().map (Pattern ::toString ).collect (Collectors .toList ());
189
+ return this .allowedOriginPatterns .stream ().map (Pattern ::toString ).collect (Collectors .toList ());
190
190
}
191
191
192
192
/**
193
193
* Add an origin pattern to allow.
194
194
*/
195
195
public void addAllowedOriginPattern (String originPattern ) {
196
- if (this .allowedOriginsPatterns == null ) {
197
- this .allowedOriginsPatterns = new ArrayList <>(4 );
196
+ if (this .allowedOriginPatterns == null ) {
197
+ this .allowedOriginPatterns = new ArrayList <>(4 );
198
198
}
199
- else if (this .allowedOriginsPatterns == DEFAULT_PERMIT_ALL_PATTERN ) {
200
- setAllowedOriginsPatterns (DEFAULT_PERMIT_ALL_PATTERN_STR );
199
+ else if (this .allowedOriginPatterns == DEFAULT_PERMIT_ALL_PATTERN ) {
200
+ setAllowedOriginPatterns (DEFAULT_PERMIT_ALL_PATTERN_STR );
201
201
}
202
- this .allowedOriginsPatterns .add (Pattern .compile (originPattern ));
202
+ this .allowedOriginPatterns .add (Pattern .compile (originPattern ));
203
203
}
204
204
205
205
/**
@@ -413,7 +413,7 @@ public Long getMaxAge() {
413
413
* </ul>
414
414
*/
415
415
public CorsConfiguration applyPermitDefaultValues () {
416
- if (this .allowedOrigins == null && this .allowedOriginsPatterns == null ) {
416
+ if (this .allowedOrigins == null && this .allowedOriginPatterns == null ) {
417
417
this .allowedOrigins = DEFAULT_PERMIT_ALL ;
418
418
}
419
419
if (this .allowedMethods == null ) {
@@ -455,13 +455,13 @@ public CorsConfiguration combine(@Nullable CorsConfiguration other) {
455
455
}
456
456
CorsConfiguration config = new CorsConfiguration (this );
457
457
List <String > combinedOrigins = combine (getAllowedOrigins (), other .getAllowedOrigins ());
458
- List <String > combinedOriginsPatterns = combine (getAllowedOriginsPatterns (), other .getAllowedOriginsPatterns ());
459
- if (combinedOrigins == DEFAULT_PERMIT_ALL && combinedOriginsPatterns != DEFAULT_PERMIT_ALL_PATTERN_STR
460
- && !CollectionUtils .isEmpty (combinedOriginsPatterns )) {
458
+ List <String > combinedOriginPatterns = combine (getAllowedOriginPatterns (), other .getAllowedOriginPatterns ());
459
+ if (combinedOrigins == DEFAULT_PERMIT_ALL && combinedOriginPatterns != DEFAULT_PERMIT_ALL_PATTERN_STR
460
+ && !CollectionUtils .isEmpty (combinedOriginPatterns )) {
461
461
combinedOrigins = null ;
462
462
}
463
463
config .setAllowedOrigins (combinedOrigins );
464
- config .setAllowedOriginsPatterns ( combinedOriginsPatterns );
464
+ config .setAllowedOriginPatterns ( combinedOriginPatterns );
465
465
config .setAllowedMethods (combine (getAllowedMethods (), other .getAllowedMethods ()));
466
466
config .setAllowedHeaders (combine (getAllowedHeaders (), other .getAllowedHeaders ()));
467
467
config .setExposedHeaders (combine (getExposedHeaders (), other .getExposedHeaders ()));
@@ -529,8 +529,8 @@ public String checkOrigin(@Nullable String requestOrigin) {
529
529
}
530
530
}
531
531
}
532
- if (!ObjectUtils .isEmpty (this .allowedOriginsPatterns )) {
533
- for (Pattern allowedOriginsPattern : this .allowedOriginsPatterns ) {
532
+ if (!ObjectUtils .isEmpty (this .allowedOriginPatterns )) {
533
+ for (Pattern allowedOriginsPattern : this .allowedOriginPatterns ) {
534
534
if (allowedOriginsPattern .pattern ().equals (ALL_PATTERN )) {
535
535
if (this .allowCredentials != Boolean .TRUE ) {
536
536
return ALL ;
0 commit comments