Fixing deletion of headers/queryargs having multiple values. (#918)

This commit is contained in:
anshul-jain-aws
2020-11-24 00:18:38 -08:00
committed by GitHub
parent cb0aaaa266
commit f710c2d320
2 changed files with 15 additions and 0 deletions
+1
View File
@@ -391,6 +391,7 @@ func delAllArgs(args []argsKV, key string) []argsKV {
tmp := *kv
copy(args[i:], args[i+1:])
n--
i--
args[n] = tmp
args = args[:n]
}
+14
View File
@@ -583,3 +583,17 @@ func testArgsParse(t *testing.T, a *Args, s string, expectedLen int, expectedArg
}
}
}
func TestArgsDeleteAll(t *testing.T) {
t.Parallel()
var a Args
a.Add("q1", "foo")
a.Add("q1", "bar")
a.Add("q1", "baz")
a.Add("q1", "quux")
a.Add("q2", "1234")
a.Del("q1")
if a.Len() != 1 || a.Has("q1") {
t.Fatalf("Expected q1 arg to be completely deleted. Current Args: %s", a.String())
}
}