@@ -164,9 +164,9 @@ func TestForwardedHost(t *testing.T) {
164
164
isError : false ,
165
165
}, {
166
166
msg : "wildcard host should match" ,
167
- host : "^([a-z0-9]+(-[a-z0-9]+)?[.]example[.]org[.]?(:[0-9]+)?)$" , // *.example.org
167
+ host : "^([a-z0-9]+(( -[a-z0-9]+)?)* [.]example[.]org[.]?(:[0-9]+)?)$" , // *.example.org
168
168
r : request {
169
- url : "https://test.example.com /index.html" ,
169
+ url : "https://test.example.org /index.html" ,
170
170
headers : http.Header {
171
171
"Forwarded" : []string {`host="test.example.org"` },
172
172
},
@@ -175,22 +175,33 @@ func TestForwardedHost(t *testing.T) {
175
175
isError : false ,
176
176
}, {
177
177
msg : "wildcard 2 host should match" ,
178
- host : "^([a-z0-9]+(-[a-z0-9]+)?[.]example[.]org[.]?(:[0-9]+)?)$" , // *.example.org
178
+ host : "^([a-z0-9]+(( -[a-z0-9]+)?)* [.]example[.]org[.]?(:[0-9]+)?)$" , // *.example.org
179
179
r : request {
180
- url : "https://test-v2.example.com /index.html" ,
180
+ url : "https://test-v2.example.org /index.html" ,
181
181
headers : http.Header {
182
182
"Forwarded" : []string {`host="test-v2.example.org"` },
183
183
},
184
184
},
185
185
matches : true ,
186
186
isError : false ,
187
187
}, {
188
- msg : "wildcard 3 host shouldn't match" ,
189
- host : "^([a-z0-9]+(-[a-z0-9]+)?[.]example[.]org[.]?(:[0-9]+)?)$" , // *.example.org
188
+ msg : "wildcard 3 host should match" ,
189
+ host : "^([a-z0-9]+(( -[a-z0-9]+)?)* [.]example[.]org[.]?(:[0-9]+)?)$" , // *.example.org
190
190
r : request {
191
- url : "https://test-.example.com /index.html" ,
191
+ url : "https://test-v2-v3 .example.org /index.html" ,
192
192
headers : http.Header {
193
- "Forwarded" : []string {`host="test-.example.com"` },
193
+ "Forwarded" : []string {`host="test-v2-v3.example.org"` },
194
+ },
195
+ },
196
+ matches : true ,
197
+ isError : false ,
198
+ }, {
199
+ msg : "wildcard 4 host shouldn't match" ,
200
+ host : "^([a-z0-9]+((-[a-z0-9]+)?)*[.]example[.]org[.]?(:[0-9]+)?)$" , // *.example.org
201
+ r : request {
202
+ url : "https://test-.example.org/index.html" ,
203
+ headers : http.Header {
204
+ "Forwarded" : []string {`host="test-.example.org"` },
194
205
},
195
206
},
196
207
matches : false ,
0 commit comments