Skip to content

Commit 0c500eb

Browse files
authored
Merge pull request #664 from suzaku/simplify
len(k) is guaranteed to be greater than 1 in this case
2 parents ca2d3e0 + 169d0fc commit 0c500eb

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

util.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ func FilterCustomQuery(u *nurl.URL) *nurl.URL {
5353
ux := *u
5454
vx := make(nurl.Values)
5555
for k, v := range ux.Query() {
56-
if len(k) <= 1 || (len(k) > 1 && k[0:2] != "x-") {
56+
if len(k) <= 1 || k[0:2] != "x-" {
5757
vx[k] = v
5858
}
5959
}

util_test.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,15 @@ func TestSuint(t *testing.T) {
2121
}
2222

2323
func TestFilterCustomQuery(t *testing.T) {
24-
n, err := nurl.Parse("foo://host?a=b&x-custom=foo&c=d")
24+
n, err := nurl.Parse("foo://host?a=b&x-custom=foo&c=d&ok=y")
2525
if err != nil {
2626
t.Fatal(err)
2727
}
2828
nx := FilterCustomQuery(n).Query()
2929
if nx.Get("x-custom") != "" {
3030
t.Fatalf("didn't expect x-custom")
3131
}
32+
if nx.Get("ok") != "y" {
33+
t.Fatalf("expected ok=y, got %v", nx.Get("ok"))
34+
}
3235
}

0 commit comments

Comments
 (0)