@@ -260,6 +260,18 @@ var hostMatcherTests = []hostMatcherTest{
260
260
vars : map [string ]string {"foo" : "abc" , "bar" : "def" , "baz" : "ghi" },
261
261
result : true ,
262
262
},
263
+ {
264
+ matcher : NewRouter ().NewRoute ().Host ("{foo:[a-z][a-z][a-z]}.{bar:[a-z][a-z][a-z]}.{baz:[a-z][a-z][a-z]}:{port:.*}" ),
265
+ url : "http://abc.def.ghi:65535/" ,
266
+ vars : map [string ]string {"foo" : "abc" , "bar" : "def" , "baz" : "ghi" , "port" : "65535" },
267
+ result : true ,
268
+ },
269
+ {
270
+ matcher : NewRouter ().NewRoute ().Host ("{foo:[a-z][a-z][a-z]}.{bar:[a-z][a-z][a-z]}.{baz:[a-z][a-z][a-z]}" ),
271
+ url : "http://abc.def.ghi:65535/" ,
272
+ vars : map [string ]string {"foo" : "abc" , "bar" : "def" , "baz" : "ghi" },
273
+ result : true ,
274
+ },
263
275
{
264
276
matcher : NewRouter ().NewRoute ().Host ("{foo:[a-z][a-z][a-z]}.{bar:[a-z][a-z][a-z]}.{baz:[a-z][a-z][a-z]}" ),
265
277
url : "http://a.b.c/" ,
@@ -365,6 +377,11 @@ var urlBuildingTests = []urlBuildingTest{
365
377
vars : []string {"subdomain" , "bar" },
366
378
url : "http://bar.domain.com" ,
367
379
},
380
+ {
381
+ route : new (Route ).Host ("{subdomain}.domain.com:{port:.*}" ),
382
+ vars : []string {"subdomain" , "bar" , "port" , "65535" },
383
+ url : "http://bar.domain.com:65535" ,
384
+ },
368
385
{
369
386
route : new (Route ).Host ("foo.domain.com" ).Path ("/articles" ),
370
387
vars : []string {},
@@ -412,7 +429,11 @@ func TestHeaderMatcher(t *testing.T) {
412
429
413
430
func TestHostMatcher (t * testing.T ) {
414
431
for _ , v := range hostMatcherTests {
415
- request , _ := http .NewRequest ("GET" , v .url , nil )
432
+ request , err := http .NewRequest ("GET" , v .url , nil )
433
+ if err != nil {
434
+ t .Errorf ("http.NewRequest failed %#v" , err )
435
+ continue
436
+ }
416
437
var routeMatch RouteMatch
417
438
result := v .matcher .Match (request , & routeMatch )
418
439
vars := routeMatch .Vars
0 commit comments