Skip to content

Commit

Permalink
Fixing deletion of headers/queryargs having multiple values. (#918)
Browse files Browse the repository at this point in the history
  • Loading branch information
anshul-jain-aws committed Nov 24, 2020
1 parent cb0aaaa commit f710c2d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions args.go
Expand Up @@ -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]
}
Expand Down
14 changes: 14 additions & 0 deletions args_test.go
Expand Up @@ -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())
}
}

0 comments on commit f710c2d

Please sign in to comment.