@@ -73,27 +73,27 @@ func TestSplitKeyValue(t *testing.T) {
7373 var k , v string
7474 var ok bool
7575
76- _ , _ , k , v , ok = splitKeyValue ("" )
76+ k , v , ok = splitKeyValue ("" )
7777 if ok {
7878 t .Error ("empty string should not OK" )
7979 }
8080
81- _ , _ , k , v , ok = splitKeyValue (":" )
81+ k , v , ok = splitKeyValue (":" )
8282 if ok {
8383 t .Error ("separator-only string should not OK" )
8484 }
8585
86- _ , _ , k , v , ok = splitKeyValue ("::world" )
86+ k , v , ok = splitKeyValue ("::world" )
8787 if ok {
8888 t .Error ("empty key should not OK" )
8989 }
9090
91- _ , _ , k , v , ok = splitKeyValue (":hello:" )
91+ k , v , ok = splitKeyValue (":hello:" )
9292 if ok {
9393 t .Error ("empty value should not OK" )
9494 }
9595
96- _ , _ , k , v , ok = splitKeyValue (":key:value" )
96+ k , v , ok = splitKeyValue (":key:value" )
9797 if ! ok {
9898 t .Fail ()
9999 }
@@ -104,7 +104,7 @@ func TestSplitKeyValue(t *testing.T) {
104104 t .Fail ()
105105 }
106106
107- _ , _ , k , v , ok = splitKeyValue ("@KEY@VALUE" )
107+ k , v , ok = splitKeyValue ("@KEY@VALUE" )
108108 if ! ok {
109109 t .Fail ()
110110 }
@@ -130,11 +130,11 @@ func TestSplitAllKeyValue(t *testing.T) {
130130}
131131
132132func TestNormalizePathRestrictAccesses (t * testing.T ) {
133- results , _ := normalizePathRestrictAccesses ([][]string {
133+ results , _ := normalizePathValues ([][]string {
134134 {"/foo" , "host1" , "host2" },
135135 {"/foo/" , "host3" , "host4" },
136136 {"/bar" },
137- }, util .NormalizeUrlPath )
137+ }, true , util .NormalizeUrlPath , util . ExtractHostsFromUrls )
138138
139139 if len (results ) != 2 {
140140 t .Error ()
@@ -148,37 +148,28 @@ func TestNormalizePathRestrictAccesses(t *testing.T) {
148148}
149149
150150func TestNormalizePathHeadersMap (t * testing.T ) {
151- var result map [ string ][][ 2 ]string
152-
153- result , _ = normalizePathHeadersMap ( []string {
154- ": /foo: X-header1: X-Value1" ,
155- ": /foo/: X-header2: X-Value2" ,
156- ": /bar: X-header3: X-Value3" ,
157- ": baz" ,
158- ": baz:" ,
159- ": baz: X-Not-Valid" ,
160- ": baz: X-Not-Valid:" ,
161- }, util .NormalizeUrlPath )
151+ var result [][ ]string
152+
153+ result , _ = normalizePathValues ([] []string {
154+ { " /foo" , " X-header1" , " X-Value1"} ,
155+ { " /foo/" , " X-header2" , " X-Value2"} ,
156+ { " /bar" , " X-header3" , " X-Value3"} ,
157+ { " baz"} ,
158+ { " baz" , "" } ,
159+ { " baz" , " X-Not-Valid"} ,
160+ { " baz" , " X-Not-Valid" , "" } ,
161+ }, false , util .NormalizeUrlPath , normalizeHeaders )
162162
163163 if len (result ) != 2 {
164164 t .Error (result )
165165 }
166166
167- if len (result ["/foo" ]) != 2 {
168- t .Error (result ["/foo" ])
169- }
170- if result ["/foo" ][0 ][0 ] != "X-header1" || result ["/foo" ][0 ][1 ] != "X-Value1" {
171- t .Error (result ["/foo" ][0 ])
172- }
173- if result ["/foo" ][1 ][0 ] != "X-header2" || result ["/foo" ][1 ][1 ] != "X-Value2" {
174- t .Error (result ["/foo" ][0 ])
167+ if ! expectStrings (result [0 ], "/foo" , "X-header1" , "X-Value1" , "X-header2" , "X-Value2" ) {
168+ t .Error (result [0 ])
175169 }
176170
177- if len (result ["/bar" ]) != 1 {
178- t .Error (result ["/foo" ])
179- }
180- if result ["/bar" ][0 ][0 ] != "X-header3" || result ["/bar" ][0 ][1 ] != "X-Value3" {
181- t .Error (result ["/foo" ][0 ])
171+ if ! expectStrings (result [1 ], "/bar" , "X-header3" , "X-Value3" ) {
172+ t .Error (result [1 ])
182173 }
183174}
184175
0 commit comments