From 4f82413d85376b873b789e79c216cc6135417302 Mon Sep 17 00:00:00 2001 From: satoru Date: Tue, 7 Dec 2021 14:50:11 +0800 Subject: [PATCH 1/2] len(k) is guaranteed to be greater than 1 in this case --- util.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util.go b/util.go index 26131a3ff..bcf90077d 100644 --- a/util.go +++ b/util.go @@ -53,7 +53,7 @@ func FilterCustomQuery(u *nurl.URL) *nurl.URL { ux := *u vx := make(nurl.Values) for k, v := range ux.Query() { - if len(k) <= 1 || (len(k) > 1 && k[0:2] != "x-") { + if len(k) <= 1 || k[0:2] != "x-" { vx[k] = v } } From 169d0fcf291395cbec65dbceacf7a26e41622f37 Mon Sep 17 00:00:00 2001 From: suzaku Date: Wed, 8 Dec 2021 10:37:49 +0800 Subject: [PATCH 2/2] Include 2 letter query param key in unit test --- util_test.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/util_test.go b/util_test.go index 1ad234473..2e8558d7a 100644 --- a/util_test.go +++ b/util_test.go @@ -21,7 +21,7 @@ func TestSuint(t *testing.T) { } func TestFilterCustomQuery(t *testing.T) { - n, err := nurl.Parse("foo://host?a=b&x-custom=foo&c=d") + n, err := nurl.Parse("foo://host?a=b&x-custom=foo&c=d&ok=y") if err != nil { t.Fatal(err) } @@ -29,4 +29,7 @@ func TestFilterCustomQuery(t *testing.T) { if nx.Get("x-custom") != "" { t.Fatalf("didn't expect x-custom") } + if nx.Get("ok") != "y" { + t.Fatalf("expected ok=y, got %v", nx.Get("ok")) + } }