diff --git a/uri.go b/uri.go index 49b30a9..a0e2744 100644 --- a/uri.go +++ b/uri.go @@ -62,7 +62,8 @@ func (u *URI) CopyTo(dst *URI) { dst.hash = append(dst.hash[:0], u.hash...) dst.host = append(dst.host[:0], u.host...) - dst.parsedQueryArgs = false + u.queryArgs.CopyTo(&dst.queryArgs) + dst.parsedQueryArgs = u.parsedQueryArgs // fullURI and requestURI shouldn't be copied, since they are created // from scratch on each FullURI() and RequestURI() call. diff --git a/uri_test.go b/uri_test.go index 5d489f5..3e519dc 100644 --- a/uri_test.go +++ b/uri_test.go @@ -7,6 +7,20 @@ import ( "time" ) +func TestURICopyToQueryArgs(t *testing.T) { + var u URI + a := u.QueryArgs() + a.Set("foo", "bar") + + var u1 URI + u.CopyTo(&u1) + a1 := u1.QueryArgs() + + if string(a1.Peek("foo")) != "bar" { + t.Fatalf("unexpected query args value %q. Expecting %q", a1.Peek("foo"), "bar") + } +} + func TestURIAcquireReleaseSequential(t *testing.T) { testURIAcquireRelease(t) }