diff --git a/client_test.go b/client_test.go index 5166afd..f5c9de9 100644 --- a/client_test.go +++ b/client_test.go @@ -112,7 +112,7 @@ func TestClientURLAuth(t *testing.T) { for up, expected := range cases { req := AcquireRequest() req.Header.SetMethod(MethodGet) - req.SetRequestURI("http://" + up + "example.com") + req.SetRequestURI("http://" + up + "example.com/foo/bar") if err := c.Do(req, nil); err != nil { t.Fatal(err) } diff --git a/uri.go b/uri.go index 9d64db8..a8b915a 100644 --- a/uri.go +++ b/uri.go @@ -284,11 +284,11 @@ func (u *URI) parse(host, uri []byte, isTLS bool) { host = host[n+1:] if n := bytes.Index(auth, strColon); n >= 0 { - u.username = auth[:n] - u.password = auth[n+1:] + u.username = append(u.username[:0], auth[:n]...) + u.password = append(u.password[:0], auth[n+1:]...) } else { - u.username = auth - u.password = auth[:0] // Make sure it's not nil + u.username = append(u.username[:0], auth...) + u.password = u.password[:0] } }